Lalit Rawat
Lalit Rawat

Reputation: 1272

Bad state: Unexpected diagnostics: Expected an identifier. [SEVERE] json_serializable:json_serializable on test/widget_test.dart

Json serilizable is not working how do i resolve this i have no idea about this error. I used flutter build_runner: ^1.7.2 json_serializable: ^3.4.1 analyzer: ^0.39.17 json_annotation: ^3.0.1 not a single file is creating json

Json serilizable is not working how do i resolve this i have no idea about this error. I used flutter build_runner: ^1.7.2 json_serializable: ^3.4.1 analyzer: ^0.39.17 json_annotation: ^3.0.1 not a single file is creating 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

Upvotes: 5

Views: 3128

Answers (1)

Kentaro Iwata
Kentaro Iwata

Reputation: 126

I encountered a similar freezed problem. It might be resolved by specifying packages.


dependencies:
  analyzer: ^0.39.14 <- This

dev_dependencies:
  build_runner: ^1.10.0 <- This

clean up before rebuild

# delete pubspec.lock
$ rm -rf pubspec.lock

# clean
$ flutter clean

cf. https://github.com/flutter/flutter/issues/63096

Upvotes: 4

Related Questions