[SEVERE] json_serializable:json_serializable on lib/user.dart (cached): Generator cannot target libraries that have not been migrated to null-safety. package:flutter_image/user.dart:11:7 ╷ 11 │ class User { │ ^^^^ ╵ [SEVERE] Failed after 74ms pub finished with exit code 1
[SEVERE] json_serializable:json_serializable on lib/user.dart (cached): Generator cannot target libraries that have not been migrated to null-safety. package:flutter_image/user.dart:11:7 ╷ 11 │ class User { │ ^^^^ ╵ [SEVERE] Failed after 74ms pub finished with exit code 1
2.3 原因
null-safety:空安全类型错误
当前Dart版本为2.7.0,小于空安全类型的最小版本2.12
1 2 3 4 5 6 7 8 9 10
Dart 2.9 Dart 2.9 didn’t add any features to the Dart language.
Dart 2.10 Dart 2.10 didn’t add any features to the Dart language, but it added an expanded dart tool that’s analogous to the Flutter SDK’s flutter tool.
Dart 2.12 Dart 2.12 added support for sound null safety. When you opt into null safety, types in your code are non-nullable by default, meaning that variables can’t contain null unless you say they can. With null safety, your runtime null-dereference errors turn into edit-time analysis errors.
In Dart 2.12, Dart FFI graduated from beta to the stable channel.