I have used the json_serializable
library in flutter and created a class and created the Annotation
of the library i.e. json_serializable in the class as below example:
import 'package:json_annotation/json_annotation.dart';
part 'AppData.g.dart';
@JsonSerializable()
class AppData {
String? Username;
String? Password;
String? Avatar;
String? Name;
String? Family;
String? FullName;
String? UserType;
String? Email;
String? Mobile;
AppData({this.Username, this.Password, this.Email,
this.Family, this.Name, this.FullName, this.UserType, this.Mobile, this.Avatar})
factory AppData.fromJson(Map<String, dynamic> json) =>
_$AppDataFromJson(json);
Map<String, dynamic> toJson() => _$AppDataToJson(this);
}
The problem is that when I type dart run build_runner build -d
in the terminal, it gives an error and does not create the AppData.g.dart
class.
You are missing a semicolon to close the AppData constructor:
AppData({this.Username, this.Password, this.Email,this.Family, this.Name, this.FullName, this.UserType, this.Mobile, this.Avatar});