flutter - 错误状态:意外诊断:需要标识符。[严重] json_serializable:json_serializable 在 test/widget_test.dart
问题描述
Json 可序列化不工作我如何解决这个我不知道这个错误。我使用了颤振 build_runner: ^1.7.2 json_serializable: ^3.4.1 分析器: ^0.39.17 json_annotation: ^3.0.1 没有一个文件正在创建 json
Json 可序列化不工作我如何解决这个我不知道这个错误。我使用了颤振 build_runner: ^1.7.2 json_serializable: ^3.4.1 分析器: ^0.39.17 json_annotation: ^3.0.1 没有一个文件正在创建 json
import 'package:dance/models/tutorials-model/video-data.dart';
import 'package:json_annotation/json_annotation.dart';
part 'metadata.g.dart';
@JsonSerializable()
class MetaData {
final String category;
final String categoryId;
final List<VideoData> data;
MetaData(this.category, this.categoryId, this.data);
factory MetaData.fromJson(Map<String, dynamic> json) => _$MetaDataFromJson(json);
Map<String, dynamic> toJson() => _$MetaDataToJson(this);
}
------------------------terminal------------------------
flutter pub run build_runner watch
[INFO] Running build...
[INFO] Generating SDK summary...
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected diagnostics:
C:\Users\Admin\Desktop\flutter-dart\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[INFO] 2.3s elapsed, 1/17 actions completed.
[INFO] 3.4s elapsed, 1/17 actions completed.
[INFO] 4.4s elapsed, 1/17 actions completed.
[INFO] 5.4s elapsed, 1/17 actions completed.
[INFO] 6.4s elapsed, 1/17 actions completed.
[INFO] 7.4s elapsed, 1/17 actions completed.
[INFO] 8.4s elapsed, 1/17 actions completed.
[INFO] 9.4s elapsed, 1/17 actions completed.
[INFO] 10.5s elapsed, 1/17 actions completed.
[INFO] 11.5s elapsed, 1/17 actions completed.
[INFO] 12.5s elapsed, 1/17 actions completed.
[INFO] 13.5s elapsed, 1/17 actions completed.
[INFO] 14.5s elapsed, 1/17 actions completed.
[INFO] 15.5s elapsed, 1/17 actions completed.
[WARNING] No actions completed for 15.0s, waiting on:
- json_serializable:json_serializable on lib/constants/constants.dart
- json_serializable:json_serializable on lib/constants/key_provider.dart
- json_serializable:json_serializable on lib/constants/routes_name.dart
- json_serializable:json_serializable on lib/constants/url_provider.dart
- json_serializable:json_serializable on lib/extension/string_extension.dart
.. and 11 more
解决方案
我遇到了类似的冻结问题。它可以通过指定包来解决。
dependencies:
analyzer: ^0.39.14 <- This
dev_dependencies:
build_runner: ^1.10.0 <- This
重建前清理
# delete pubspec.lock
$ rm -rf pubspec.lock
# clean
$ flutter clean
推荐阅读
- react-native - React Native Apollo client.query 没有从应用同步中获取更新的数据 - dynamo db
- javascript - 输入类型 FILE 多个 - 一个一个添加文件
- html - 带有来自 Amazon S3 的图像的 Img 标签不起作用
- php - PHP 无法在表单提交上设置会话令牌
- python - 如何在 Python 中使用值设置特定索引
- ios - 创建一个适合快速预约的自定义 UIDatePicker
- ada - Enabling "--enable-stdcall-fixup" flag with gnatmake?
- javascript - 编辑 HTML/CSS 主题,似乎无法使其显示已售罄
- javascript - 如何将 div 克隆放在原始 div 的正下方?
- java - 在 webview 中覆盖 window.print()