gpt4 book ai didi

flutter - 生成器无法定位尚未迁移到空安全的库

转载 作者:行者123 更新时间:2023-12-04 10:54:22 26 4
gpt4 key购买 nike

尝试以下命令时会出现此问题: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
我被困在这一点上,如何解决这个问题。

最佳答案

我发现 json_serializable >=4.0.0取决于 json_annotation >=4.0.0 <4.1.0json_annotation: ^4.0.0包括 Null Safety但是 json_serializable: ^4.0.2 ,所以错误正在发生。
所以我降级了两个包:

json_annotation: 3.1.1
json_serializable: 3.5.1
他们再次正常工作。

关于flutter - 生成器无法定位尚未迁移到空安全的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66477445/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com