Skip to content

Instantly share code, notes, and snippets.

@hjJunior
Last active June 10, 2019 12:29
Show Gist options
  • Save hjJunior/a354866407fd95bb885a6aeb6a5b89db to your computer and use it in GitHub Desktop.
Save hjJunior/a354866407fd95bb885a6aeb6a5b89db to your computer and use it in GitHub Desktop.
@JsonSerializable(nullable: false)
class Person {
final String firstName;
final String lastName;
Person({this.firstName, this.lastName});
factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);
Map<String, dynamic> toJson() => _$PersonToJson(this);
}
Person _$PersonFromJson(Map<String, dynamic> json) {
return Person(
firstName: json['firstName'] as String,
lastName: json['lastName'] as String);
}
Map<String, dynamic> _$PersonToJson(Person instance) => <String, dynamic>{
'firstName': instance.firstName,
'lastName': instance.lastName
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment