flutter pub run build_runner build——delete- conflict冲突-outpu



我想在github action中运行此命令以在flutter(2.x)中生成json可序列化文件,我使用json_serializable lib:

flutter pub run build_runner build --delete-conflicting-outputs

但是这个命令运行失败,我没有从日志输出中找到任何错误消息,日志看起来像这样:

Run flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 666ms
[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 8.5s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 913ms
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Deleting 10 declared outputs which already existed on disk.
[INFO] Checking for unexpected pre-existing outputs. completed, took 4ms
[INFO] Running build...
[INFO] Generating SDK summary...
[INFO] 4.5s elapsed, 0/16 actions completed.
[INFO] Generating SDK summary completed, took 4.4s
[INFO] 5.5s elapsed, 0/16 actions completed.
[INFO] 6.5s elapsed, 0/16 actions completed.
[INFO] 7.5s elapsed, 0/16 actions completed.
[INFO] 8.6s elapsed, 0/16 actions completed.
[INFO] 9.6s elapsed, 0/16 actions completed.
[INFO] 10.7s elapsed, 0/16 actions completed.
[INFO] 11.8s elapsed, 0/16 actions completed.
[INFO] 12.9s elapsed, 0/16 actions completed.
[INFO] 14.0s elapsed, 0/16 actions completed.
Warning:  No actions completed for 15.0s, waiting on:
- json_serializable:json_serializable on lib/main.dart
- json_serializable:json_serializable on lib/part/part.dart
- json_serializable:json_serializable on lib/material/hero.dart
- json_serializable:json_serializable on lib/material/app.dart
- json_serializable:json_serializable on lib/material/user.dart
.. and 11 more
[INFO] 25.7s elapsed, 0/16 actions completed.
[SEVERE] json_serializable:json_serializable on lib/material/button.dart:
The version constraint "any" on json_annotation allows versions before 4.3.0 which is not allowed.
[INFO] 27.7s elapsed, 1/17 actions completed.
[INFO] 33.0s elapsed, 6/22 actions completed.
[INFO] 34.1s elapsed, 28/43 actions completed.
[INFO] 35.1s elapsed, 37/53 actions completed.
[INFO] 36.1s elapsed, 42/57 actions completed.
[SEVERE] json_serializable:json_serializable on test/pages/my_collection_page_test.dart:
The version constraint "any" on json_annotation allows versions before 4.3.0 which is not allowed.
[INFO] 38.6s elapsed, 54/70 actions completed.
[INFO] 39.7s elapsed, 63/77 actions completed.
[INFO] 40.8s elapsed, 87/103 actions completed.
[INFO] 41.9s elapsed, 115/129 actions completed.
Warning:  json_serializable:json_serializable on lib/repository/objects/music_count.dart:
The constructor parameter for `artistCount` has a default value `0`, but the `JsonKey.defaultValue` value `0` will be used for missing or `null` values in JSON decoding.
Warning:  json_serializable:json_serializable on lib/repository/objects/music_count.dart:
The constructor parameter for `djRadioCount` has a default value `0`, but the `JsonKey.defaultValue` value `0` will be used for missing or `null` values in JSON decoding.
Warning:  json_serializable:json_serializable on lib/repository/objects/music_count.dart:
The constructor parameter for `mvCount` has a default value `0`, but the `JsonKey.defaultValue` value `0` will be used for missing or `null` values in JSON decoding.
Warning:  json_serializable:json_serializable on lib/repository/objects/music_count.dart:
The constructor parameter for `createDjRadioCount` has a default value `0`, but the `JsonKey.defaultValue` value `0` will be used for missing or `null` values in JSON decoding.
Warning:  json_serializable:json_serializable on lib/repository/objects/music_count.dart:
The constructor parameter for `createdPlaylistCount` has a default value `0`, but the `JsonKey.defaultValue` value `0` will be used for missing or `null` values in JSON decoding.
Warning:  json_serializable:json_serializable on lib/repository/objects/music_count.dart:
The constructor parameter for `subPlaylistCount` has a default value `0`, but the `JsonKey.defaultValue` value `0` will be used for missing or `null` values in JSON decoding.
[INFO] 43.7s elapsed, 166/182 actions completed.
[INFO] 44.8s elapsed, 199/215 actions completed.
[INFO] 45.8s elapsed, 232/246 actions completed.
[INFO] 46.9s elapsed, 264/280 actions completed.
[INFO] 47.9s elapsed, 404/405 actions completed.
Warning:  source_gen:combining_builder on lib/model/fav_music.dart:
fav_music.g.dart must be included as a part directive in the input library with:
part 'fav_music.g.dart';
[INFO] Running build completed, took 48.3s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 308ms
[SEVERE] Failed after 48.6s
pub finished with exit code 1
Error: Process completed with exit code 1.

哪里出了问题?我该怎么做才能解决这个问题?

您可以尝试将这行添加到文件fav_music.dart?

part 'fav_music.g.dart';

的例子:

part 'fav_music.g.dart';
@JsonSerializable()
class FavMusic {
int status;

最新更新