当前位置: 首页 > 知识库问答 >
问题:

新的颤振更新强制零安全?

郭翰翮
2023-03-14
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.

是否有任何方法可以从代码中删除空安全检查,或者我现在被迫进行迁移?(工作量很大)。

共有1个答案

洪念
2023-03-14

我设法让我的项目工作:

  1. 在pub spec.yaml中设置SDK:“>=2.7.0<2.12.0”
  2. 重新启动IDE
  3. 运行flutter clean
  4. 运行颤振创建。

对我来说,这似乎是一个bug,因为如果再次运行flutter clean,整个项目将回到使用null-safety。

 类似资料:
  • 我正试图将我的颤振项目更新为颤振稳定2.0.3,但出现了错误: 因为sdk的每个版本的flutter_driver都依赖于网络驱动程序2.1.2,它依赖于存档 有人知道如何解决这个问题吗?我试图导入webdriver版本为^3.0.0的软件包,但在尝试运行应用程序时,出现了错误: 由于sdk中的每个版本的flatter\u驱动程序都依赖于webdriver 2.1.2,而应用程序依赖于webdri

  • 我想使用带有Flutter的dart SDK>=2.2.0。但我目前使用的Flutter版本是2.1.2 我尝试独立安装2.2.0版本,并成功了: 然而,Flutter并没有使用你在上面看到的这个版本。我试图用独立安装的版本替换flutter使用的()文件,但是当我尝试运行flutter之后出现快照问题,因此我将原来的文件夹放回flutter目录中。 你有什么想法我该怎么更新它吗? PS:我最近(

  • 在更新到飘飘 2.8 之前 更新到飘飘 2.8 后: 如何更新minSdkVersion更高?我在任何地方都找不到目标“flutter.minSdkVersion”变量。

  • flutter似乎在空安全检查和非空安全检查之间切换,导致了几十个问题。 空错误检查返回???

  • 最近我收到一封来自Google的邮件,要求我更新OpenSSL,否则我的应用程序将被阻止。他们提到了检查OpenSSl版本的步骤,我做了,发现我的东西,如MD5 SHA(加密算法)使用的是1.0.1h版本。 我的问题是我如何更新这些,因为我已经在使用最新的JDK,这些只是其中的一部分。请建议我该怎么办? IDE:Android Studio 2.0 buildToolsVersion " 21 .