Home > Software design >  Code does not work, after adding automatically generated serialization and deserialization. Flutter
Code does not work, after adding automatically generated serialization and deserialization. Flutter

Time:01-08

Code does not work, after adding automatically generated serialization and deserialization. After I wrote "flutter pub run build_runner build" in the terminal. When I run the main file I get the error shown in the photo.

CodePudding user response:

start with your View then run "flutter packages pub run build_runner build" and a .g file will be generated automatically

@JsonSerializable()
class PersonView {
  final String lastName;
  final String firstName;

  PersonView(
      this.lastName,
      this.firstName,
);

  factory PersonView.fromJson(Map<String, dynamic> json) =>
      _$PersonViewFromJson(json);

  Map<String, dynamic> toJson() => _$PersonViewToJson(this);
}

CodePudding user response:

try running with the delete-conflicting-outputs flag

flutter pub run build_runner build --delete-conflicting-outputs
  •  Tags:  
  • Related