分析器需要启用'non-nullable'语言功能



我犯了一个错误,迁移到空安全,然后每件事都变成了错误,在修复了很多错误后,我仍然会得到一个错误。错误是:

[INFO] Generating build script...
[INFO] Generating build script completed, took 452ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 131ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 791ms
[INFO] Running build...
[INFO] Running build completed, took 30ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 79ms
[SEVERE] json_serializable:json_serializable on lib/injection.config.dart (cached):
This builder requires Dart inputs without syntax errors.
However, package:invoice_app/injection.config.dart (or an existing part) contains the following errors.
injection.config.dart:18:48: This requires the 'non-nullable' language feature to be enabled.
injection.config.dart:18:12: This requires the 'non-nullable' language feature to be enabled.
Try fixing the errors and re-running the build.
[SEVERE] Failed after 123ms
pub finished with exit code 1

看起来可注射生成器与新版本的dart有一些混淆,这就是为什么当我生成新的injection.config.dart文件时,它给出了这个错误

injection.config.dart:18:12:这需要启用"不可为null"的语言功能。

所以如果你想修复它,只需打开文件,然后从这个中删除?标记

_i1.GetIt $initGetIt(_i1.GetIt get,
{String? environment, _i2.EnvironmentFilter? environmentFilter}) {
final gh = _i2.GetItHelper(get, environment, environmentFilter);
return get;
}

到这个

_i1.GetIt $initGetIt(_i1.GetIt get,
{String environment, _i2.EnvironmentFilter environmentFilter}) {
final gh = _i2.GetItHelper(get, environment, environmentFilter);
return get;
}

我知道这不是一个解决方案,但它一直有效,直到我迁移到不可为null时,我才会使用它。

相关内容

  • 没有找到相关文章

最新更新