flutter - 我迁移到了空安全,我无法运行“flutter pub run build_runner build”而不抛出错误
问题描述
我已添加// @dart=2.9
到我的所有文件中,但build_runner
不会抛出此错误:
Warning: Operand of null-aware operation '?.' has type 'SendPort' which excludes null. - 'SendPort' is from 'dart:isolate'. sendPort?.send(result); ^Error: Cannot run with sound null safety, because the following dependencies don't support null safety:
- package:build_runner_core
- package:json_serializable
- package:moor_generator
- package:objectbox_generator
- package:retrofit_generator
- package:source_gen
- package:build_config
- package:build_runner
- package:build
- package:json_annotation
- package:glob
- package:pool
- package:crypto
- package:logging
- package:watcher
- package:build_resolvers
- package:timing
- package:graphs
- package:package_config
- package:yaml
- package:analyzer
- package:sqlparser
- package:objectbox
- package:dart_style
- package:built_collection
- package:code_builder
- package:dio
- package:tuple
- package:retrofit
- package:pedantic
- package:checked_yaml
- package:pubspec_parse
- package:build_daemon
- package:args
- package:io
- package:convert
- package:pub_semver
- package:ffi
- package:quiver
- package:moor
- package:recase
- package:_fe_analyzer_shared
- package:built_value
- package:http_parser
- package:http_multi_server
- package:shelf
- package:stream_transform
- package:mime
- package:shelf_web_socket
- package:web_socket_channel
- package:cli_util
- package:fixnum
- package:synchronizedFor solutions, see https://dart.dev/go/unsound-null-safety.dart_tool/build/entrypoint/build.dart:44:44: Error: The parameter 'sendPort' can't have a value of 'null' because of its type 'SendPort', but the implicit default value is 'null'. - 'SendPort' is from 'dart:isolate'.Try adding either an explicit non-'null' default value or the 'required' modifier.void main(List<String> args, [_i8.SendPort sendPort]) async {
解决方案
请确保您的所有软件包都更新到各自的空安全版本。对于构建^1.12.2
运行器,请在当前工作目录中使用,然后在终端中运行以下命令。
flutter clean
flutter pub cache repair
flutter pub run build_runner clean
flutter pub get
然后运行构建运行器命令。
这对我有用,我已经使用构建运行器成功生成了文件。
推荐阅读
- influxdb - 手动按特定顺序排序
- matlab - 使用 histfit 拟合正态分布时指定 bin 边缘
- python - 空行对训练 FastText 模型的影响
- angular - NgRx 数组状态如何修复类型约定?
- artifactory - JFrog Xray 可以只扫描 Maven 工件吗?
- python - Pygame - 接地时平台跳跃无响应
- google-cloud-platform - GCP HTTP(s) 第 7 层负载平衡器中的动态 SSL 分配
- c++ - 不删除静态指针(谷歌风格)
- python - 使用 GridSearchCV 时出现什么错误?
- apache-kafka - Ktable 到 KGroupTable - 架构不可用(状态存储 ChangeLog 架构未注册)