【发布时间】:2021-12-16 07:03:21
【问题描述】:
目前我正在尝试运行一个自动生成响应文件的项目。但是我在运行 build_runner cmd 时遇到了一些错误。
自动生成文件的命令:
flutter pub run build_runner build
以下是我得到的错误:
Bad state: Unexpected diagnostics:
/Users/user/development/flutter/bin/cache/dart-sdk/lib/internal/internal.dart:691:16 - This requires the 'non-nullable' language feature to be enabled.
[SEVERE] json_serializable:json_serializable on lib/database/database_helper.dart:
Bad state: Unexpected diagnostics:
/Users/user/development/flutter/bin/cache/dart-sdk/lib/internal/internal.dart:691:16 - This requires the 'non-nullable' language feature to be enabled.
[INFO] 1.7s elapsed, 1/17 actions completed.
[INFO] 2.8s elapsed, 1/17 actions completed.
[INFO] 3.9s elapsed, 1/17 actions completed.
[INFO] 5.0s elapsed, 1/17 actions completed.
[INFO] 6.0s elapsed, 1/17 actions completed.
这仍然是无限循环,永远不会结束。
为什么会发生这种情况?
环境改成sdk: ">=2.12.0 <3.0.0"
但这是我在运行命令时遇到的错误:
[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
[SEVERE] .dart_tool/build/entrypoint/build.dart:27:3: 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 dependenciesdon't support null safety: - package:build_runner_core - package:json_serializable - package:retrofit_generator - package:source_gen - package:build_config - package:build_runner - package:build - package:json_annotation - package:glob - package:crypto - package:logging - package:watcher - package:build_resolvers - package:timing - package:graphs - package:package_config - package:yaml - package:analyzer - package:built_collection - package:code_builder - package:dart_style - package:dio - package:tuple - package:retrofit - package:checked_yaml - package:pubspec_parse - package:build_daemon - package:args - package:io - package:convert - package:pub_semver - package:quiver - 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:fixnumFor solutions, see https://dart.dev/go/unsound-null-safety.dart_tool/build/entrypoint/build.dart:25: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, [_i6.SendPort sendPort]) async {
【问题讨论】:
-
你试过this吗?
-
是的,我每次运行 cmd 时都会这样做。我不认为它 releted 哟这个
标签: flutter dart build-runner