- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚更新到 flutter 版本 1.25.0-5.0.pre.92,我的代码中出现了很多与空安全相关的错误,这些错误以前运行良好。我没有以任何方式选择空安全,我所做的只是运行 flutter 升级,现在它假设我想使用空安全。
这些是错误:
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:165:81: Error: The parameter 'rowKeys' can't have a value of 'null' because of its type 'List<Key>', but the implicit default value is 'null'.
- 'List' is from 'dart:core'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../sdk/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Widget _getCol3(BuildContext context, ScrollController controller, [List<Key> rowKeys]){
^^^^^^^
org-dartlang-app:/change_notifiers/theme_parameters.dart:17:5: Error: The value 'null' can't be assigned to a variable of type 'ThemeData' because 'ThemeData' is not nullable.
- 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../sdk/flutter/packages/flutter/lib/src/material/theme_data.dart').
null,
^
org-dartlang-app:/change_notifiers/theme_parameters.dart:27:35: Error: Method 'withOpacity' cannot be called on 'Color?' because it is potentially null.
- 'Color' is from 'dart:ui'.
Try calling using ?. instead.
color: Colors.grey[700].withOpacity(0.9),
^^^^^^^^^^^
org-dartlang-app:/change_notifiers/theme_parameters.dart:45:37: Error: Method 'withOpacity' cannot be called on 'Color?' because it is potentially null.
- 'Color' is from 'dart:ui'.
Try calling using ?. instead.
color: Colors.grey[700].withOpacity(0.9),
^^^^^^^^^^^
org-dartlang-app:/pages/heroes/page_heroes.dart:86:42: Error: The value 'null' can't be assigned to a variable of type 'Widget Function(BuildContext, Animation<double>, HeroFlightDirection, BuildContext, BuildContext)' because 'Widget Function(BuildContext, Animation<double>, HeroFlightDirection, BuildContext, BuildContext)' is not nullable.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'Animation' is from 'package:flutter/src/animation/animation.dart' ('../sdk/flutter/packages/flutter/lib/src/animation/animation.dart').
- 'HeroFlightDirection' is from 'package:flutter/src/widgets/heroes.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/heroes.dart').
shuttleBuilder = null;
^
org-dartlang-app:/pages/heroes/page_heroes.dart:88:47: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
^^^^^^^^^^^^^^^^^^^^
org-dartlang-app:/pages/heroes/page_heroes.dart:103:47: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
^^^^^^^^^^^^^^^^^^^^
org-dartlang-app:/pages/heroes/page_heroes.dart:116:42: Error: The value 'null' can't be assigned to a variable of type 'Widget Function(BuildContext, Animation<double>, HeroFlightDirection, BuildContext, BuildContext)' because 'Widget Function(BuildContext, Animation<double>, HeroFlightDirection, BuildContext, BuildContext)' is not nullable.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'Animation' is from 'package:flutter/src/animation/animation.dart' ('../sdk/flutter/packages/flutter/lib/src/animation/animation.dart').
- 'HeroFlightDirection' is from 'package:flutter/src/widgets/heroes.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/heroes.dart').
shuttleBuilder = null;
^
org-dartlang-app:/pages/heroes/page_heroes.dart:118:47: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
^^^^^^^^^^^^^^^^^^^^
org-dartlang-app:/pages/heroes/page_heroes.dart:133:47: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
^^^^^^^^^^^^^^^^^^^^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:37:5: Error: The value 'null' can't be assigned to a variable of type 'TextEditingController' because 'TextEditingController' is not nullable.
- 'TextEditingController' is from 'package:flutter/src/widgets/editable_text.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/editable_text.dart').
null,
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:38:5: Error: The value 'null' can't be assigned to a variable of type 'TextEditingController' because 'TextEditingController' is not nullable.
- 'TextEditingController' is from 'package:flutter/src/widgets/editable_text.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/editable_text.dart').
null,
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:180:35: Error: The getter 'text' isn't defined for the class 'Object?'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'text'.
value = value.text;
^^^^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:183:33: Error: The argument type 'Object?' can't be assigned to the parameter type 'String'.
- 'Object' is from 'dart:core'.
return Text(value, style: Theme.of(context).textTheme.headline3,);
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:243:29: Error: The value 'null' can't be assigned to a variable of type 'Color' because 'Color' is not nullable.
- 'Color' is from 'dart:ui'.
colBackgroundColors: [null, null, null, Colors.green.withOpacity(0.4), Colors.red.withOpacity(0.4)],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:243:35: Error: The value 'null' can't be assigned to a variable of type 'Color' because 'Color' is not nullable.
- 'Color' is from 'dart:ui'.
colBackgroundColors: [null, null, null, Colors.green.withOpacity(0.4), Colors.red.withOpacity(0.4)],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:243:41: Error: The value 'null' can't be assigned to a variable of type 'Color' because 'Color' is not nullable.
- 'Color' is from 'dart:ui'.
colBackgroundColors: [null, null, null, Colors.green.withOpacity(0.4), Colors.red.withOpacity(0.4)],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:244:29: Error: The value 'null' can't be assigned to a variable of type 'Color' because 'Color' is not nullable.
- 'Color' is from 'dart:ui'.
rowBackgroundColors: [null, null, null, null, Colors.indigo.withOpacity(0.4)],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:244:35: Error: The value 'null' can't be assigned to a variable of type 'Color' because 'Color' is not nullable.
- 'Color' is from 'dart:ui'.
rowBackgroundColors: [null, null, null, null, Colors.indigo.withOpacity(0.4)],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:244:41: Error: The value 'null' can't be assigned to a variable of type 'Color' because 'Color' is not nullable.
- 'Color' is from 'dart:ui'.
rowBackgroundColors: [null, null, null, null, Colors.indigo.withOpacity(0.4)],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:244:47: Error: The value 'null' can't be assigned to a variable of type 'Color' because 'Color' is not nullable.
- 'Color' is from 'dart:ui'.
rowBackgroundColors: [null, null, null, null, Colors.indigo.withOpacity(0.4)],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:246:26: Error: The value 'null' can't be assigned to a variable of type 'TextAlign' because 'TextAlign' is not nullable.
- 'TextAlign' is from 'dart:ui'.
columnAlignments: [null, null, null, null, TextAlign.right],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:246:32: Error: The value 'null' can't be assigned to a variable of type 'TextAlign' because 'TextAlign' is not nullable.
- 'TextAlign' is from 'dart:ui'.
columnAlignments: [null, null, null, null, TextAlign.right],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:246:38: Error: The value 'null' can't be assigned to a variable of type 'TextAlign' because 'TextAlign' is not nullable.
- 'TextAlign' is from 'dart:ui'.
columnAlignments: [null, null, null, null, TextAlign.right],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:246:44: Error: The value 'null' can't be assigned to a variable of type 'TextAlign' because 'TextAlign' is not nullable.
- 'TextAlign' is from 'dart:ui'.
columnAlignments: [null, null, null, null, TextAlign.right],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:247:19: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
colStyles: [null, null, null, null, Theme.of(context).textTheme.caption],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:247:25: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
colStyles: [null, null, null, null, Theme.of(context).textTheme.caption],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:247:31: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
colStyles: [null, null, null, null, Theme.of(context).textTheme.caption],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:247:37: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
colStyles: [null, null, null, null, Theme.of(context).textTheme.caption],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:247:71: Error: A value of type 'TextStyle?' can't be assigned to a variable of type 'TextStyle' because 'TextStyle?' is nullable and 'TextStyle' isn't.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
colStyles: [null, null, null, null, Theme.of(context).textTheme.caption],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:248:19: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
rowStyles: [null, null, null, null, Theme.of(context).textTheme.headline6],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:248:25: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
rowStyles: [null, null, null, null, Theme.of(context).textTheme.headline6],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:248:31: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
rowStyles: [null, null, null, null, Theme.of(context).textTheme.headline6],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:248:37: Error: The value 'null' can't be assigned to a variable of type 'TextStyle' because 'TextStyle' is not nullable.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
rowStyles: [null, null, null, null, Theme.of(context).textTheme.headline6],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:248:71: Error: A value of type 'TextStyle?' can't be assigned to a variable of type 'TextStyle' because 'TextStyle?' is nullable and 'TextStyle' isn't.
- 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../sdk/flutter/packages/flutter/lib/src/painting/text_style.dart').
rowStyles: [null, null, null, null, Theme.of(context).textTheme.headline6],
^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:260:47: Error: The value 'null' can't be assigned to a variable of type 'bool' because 'bool' is not nullable.
selected[rowsIds.indexOf(row.id)] = null;
^
/C:/Users/Dayan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/extended_image-1.1.0/lib/src/extended_image.dart:786:44: Error: No named parameter with the name 'nullOk'.
_invertColors = MediaQuery.of(context, nullOk: true)?.invertColors ??
^^^^^^
../sdk/flutter/packages/flutter/lib/src/widgets/media_query.dart:818:25: Context: Found this candidate, but the arguments don't match.
static MediaQueryData of(BuildContext context) {
^^
/C:/Users/Dayan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/wave-0.0.8/lib/config.dart:46:13: Error: Method not found: 'throwNullError'.
throwNullError('custom', 'colors` or `gradients');
^^^^^^^^^^^^^^
/C:/Users/Dayan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/wave-0.0.8/lib/config.dart:60:13: Error: Method not found: 'throwNullError'.
throwNullError('custom', 'durations');
^^^^^^^^^^^^^^
/C:/Users/Dayan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/wave-0.0.8/lib/config.dart:66:13: Error: Method not found: 'throwNullError'.
throwNullError('custom', 'heightPercentages');
^^^^^^^^^^^^^^
org-dartlang-app:/pages/future_handling/page_future_handling.dart:32:10: Error: Field 'widgetToExport' should be initialized because its type 'Widget' doesn't allow null.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
Widget widgetToExport;
^^^^^^^^^^^^^^
org-dartlang-app:/pages/future_handling/page_future_handling.dart:82:13: Error: Field 'widgetToExportKey' should be initialized because its type 'GlobalKey<State<StatefulWidget>>' doesn't allow null.
- 'GlobalKey' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'State' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'StatefulWidget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
GlobalKey widgetToExportKey;
^^^^^^^^^^^^^^^^^
org-dartlang-app:/pages/heroes/page_heroes.dart:33:10: Error: Field 'widgetToExport' should be initialized because its type 'Widget' doesn't allow null.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
Widget widgetToExport;
^^^^^^^^^^^^^^
org-dartlang-app:/pages/heroes/page_heroes.dart:34:28: Error: Field 'shuttleBuilder' should be initialized because its type 'Widget Function(BuildContext, Animation<double>, HeroFlightDirection, BuildContext, BuildContext)' doesn't allow null.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'Animation' is from 'package:flutter/src/animation/animation.dart' ('../sdk/flutter/packages/flutter/lib/src/animation/animation.dart').
- 'HeroFlightDirection' is from 'package:flutter/src/widgets/heroes.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/heroes.dart').
HeroFlightShuttleBuilder shuttleBuilder;
^^^^^^^^^^^^^^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:30:10: Error: Field 'col1' should be initialized because its type 'Widget' doesn't allow null.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
Widget col1;
^^^^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:31:10: Error: Field 'col2' should be initialized because its type 'Widget' doesn't allow null.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
Widget col2;
^^^^
org-dartlang-app:/pages/lightweight_table/page_lightweight_table.dart:32:10: Error: Field 'col3' should be initialized because its type 'Widget' doesn't allow null.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
Widget col3;
^^^^
Failed to compile application.
有没有办法从我的代码中删除空安全检查,或者我现在是否被迫进行迁移? (这是很多工作)。
最佳答案
我设法通过以下方式使我的项目工作:
sdk: ">=2.7.0 <2.12.0"
在 pub spec.yaml 中 flutter clean
flutter create .
flutter clean
再次,整个项目回到使用空安全。
关于flutter - 新的 flutter 更新强制无效安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65184126/
我有一个接受以下参数的函数: int setvalue(void (*)(void *)); 为了满足参数:void (*)(void *),我创建了这样一个函数: static void *
我有以下代码: typedef void VOID; int f(void); int g(VOID); 在 C 中编译得很好(在 Fedora 10 上使用 gcc 4.3.2)。与 C++ 编译的
这个问题已经有答案了: Is f(void) deprecated in modern C and C++? [duplicate] (6 个回答) 已关闭 7 年前。 B.A.T.M.A.N./A.
我在 ASP.NET Core 3.1 项目上有以下 Identity Server 4 配置: services .AddIdentityServer(y => { y.Events.R
我们有一个 O365 租户,一切都是开箱即用的。租户放置在德国云中,而不是全局 (office.de) 中。我们还开发了一个 Office 插件,使用 OAuth 2.0 授权访问共享点。首先,我们向
我有一个如下所示的路由 routes.MapRoute( name: "Default", url: "{controller}/{action}/{i
我正在尝试使用 OAuth2.0 访问 google 文档。我已经从 Google API 控制台获取了客户端 ID 和 key 。但是当我运行这段代码时,我收到了异常。如果我遗漏了什么,有人可以建议
此代码有效: let mut b: Vec = Vec::with_capacity(a.len()); for val in a.iter() { b.push(val); } 此代码不起作
使用 client_credintials 授权类型请求 EWS oauth2 v2.0 的访问 token 时出现错误。 https://login.microsoftonline.com/tena
我通过 Java 应用程序使用 Google 电子表格时遇到了问题。我创建了应用程序,该应用程序运行了 1 年多,没有任何问题,我什至在 Create Spreadsheet using Google
如何创建 匹配所有无效 Base64 字符的正则表达式?我在堆栈上找到了 [^a-zA-Z0-9+/=\n\r].*$ 但是当我尝试时我得到了带有 - 符号的结果字符串.我根本不知道正则表达式,任何人
我从 Gitlab CI/CD Pipelines 获得错误信息:yaml invalid。问题是由 .gitlab-ci.yml 脚本的第五行引起的: - 'ssh deployer@gita
我有 3 个数据源,设置如下: @Configuration @Component public class DataSourceConfig { @Bean("foo") @Conf
你好,我想用bulkCreate ex 插入数据: [ { "typeId": 5, "devEui": "0094E796CBFCFEF9", "application_name": "Pressu
UIApplicationExitsOnSuspend 不会强制我的应用程序退出。我已经清理过目标、删除了应用程序、重建并重新安装了很多次。 我确实需要退出我的应用程序。 最佳答案 您是否链接了 SD
在 iPhone 配置门户上,显示我的 iPhone 团队配置配置文件无效。有一个“由 Xcode 管理”文本。 “续订”按钮被禁用。 我该如何解决这个问题?谢谢 最佳答案 使用 Xcode 3.2.
好的,所以今天我用我们的“实时”数据库中的新信息更新了我的数据库……从那时起,我的一个表格就出现了问题。如果您需要任何代码,请告诉我,我将对其进行编辑并发布所需的代码... 我有一个报告表格,其中有一
我有一个结构体,其中有一个元素表示为 void (*func)(); 我知道 void 指针通常用于函数指针,但我似乎无法定义该函数。我不断收到取消引用指向不完整类型的指针。我用谷歌搜索了一下但没有结
我正在尝试使用 Coldfusion 9 从 ning 网络获取凭证,所以首先这是测试 api 的 curl 语法: curl -k https://external.ningapis.com/xn/
这个问题已经有答案了: Does C have references? (2 个回答) 已关闭 4 年前。 我正在学习 C 语言引用,这是我的代码: #include int main(void)
我是一名优秀的程序员,十分优秀!