尝试执行以下命令时出现此问题:
flutter pub run build_runner build --delete-conflicting-outputs
错误消息:
[SEVERE] json_serializable:json_serializable on lib/models/shipping_address/shipping_address.dart:
Generator cannot target libraries that have not been migrated to null-safety.
package:deals_and_delivery/models/shipping_address/shipping_address.dart:6:7
╷
6 │ class ShippingAddress {
│ ^^^^^^^^^^^^^^^
╵
[INFO] Running build completed, took 3.6s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 49ms
[SEVERE] Failed after 3.7s
pub finished with exit code 1
pubspec.yaml:
dependencies:
json_annotation: ^4.0.0
flutter:
sdk: flutter
...
dev_dependencies:
build_runner: ^1.11.5
json_serializable: ^4.0.2
flutter_test:
sdk: flutter
这是当前的Flutter和Dart版本:
[√] Flutter (Channel stable, 2.0.0, on Microsoft Windows [Version
> 10.0.19042.844], locale en-US)
> • Flutter version 2.0.0 at C:\flutter
> • Framework revision 60bd88df91 (22 hours ago), 2021-03-03 09:13:17 -0800
> • Engine revision 40441def69
> • Dart version 2.12.0
我卡在这一点上了,如何解决这个问题。
依赖于build_runner 1.12.2和json_serializable 3.5.1,版本解决失败。
- Oliver Dixon