gpt4 book ai didi

flutter - 错误 : This requires the 'non-nullable' experiment to be enabled

转载 作者:行者123 更新时间:2023-12-04 12:56:42 27 4
gpt4 key购买 nike

我在玩不可为空的类型并将其添加到我的 analysis_options.yaml :

analyzer:
enable-experiment:
- non-nullable

我有一个使用可空性扩展的代码生成器。 Visual Code 对我的代码很好。

现在,我尝试运行:
flutter packages pub run build_runner watch 

我收到此错误消息:
[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
[SEVERE] xyz.dart:95:7: Error: This requires the 'non-nullable' experiment to be enabled.Try enabling this experiment by adding it to the command line when compiling and running.

如何通过 --enable-experiment:non-nullableflutter packages pub run ?

如果我运行,也会发生同样的情况:
flutter build ios

我收到错误消息:
  lib/main.dart:61:26: Error: This requires the 'non-nullable' experiment to be enabled.

Try enabling this experiment by adding it to the command line when compiling and running.

所以,同样的问题:我怎样才能通过 --enable-experiment:non-nullableflutter build ?

最佳答案

这个问题是我升级 Flutter 后出现的。
我通过 解决了它清理和升级项目依赖项 再次。
在项目根目录下运行以下命令:

flutter clean
flutter packages pub upgrade
flutter pub run build_runner build
也正如其他人所说,请确保您的 sdk 版本在 pubspec.yaml 中与您的 flutter sdk 版本兼容。

关于flutter - 错误 : This requires the 'non-nullable' experiment to be enabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57934341/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com