Created
January 1, 2021 14:51
-
-
Save CoderJava/c5c82ed779a46c4a5b6a69b864338f1f to your computer and use it in GitHub Desktop.
Class model profile_data.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
part 'profile_data.g.dart'; | |
@JsonSerializable() | |
class ProfileData { | |
@JsonKey(name: 'id') | |
final int id; | |
@JsonKey(name: 'name') | |
final String name; | |
@JsonKey(name: 'email') | |
final String email; | |
@JsonKey(name: 'age') | |
final int age; | |
ProfileData( | |
this.id, | |
this.name, | |
this.email, | |
this.age, | |
); | |
factory ProfileData.fromJson(Map<String, dynamic> json) => _$ProfileDataFromJson(json); | |
Map<String, dynamic> toJson() => _$ProfileDataToJson(this); | |
@override | |
String toString() { | |
return 'ProfileData{id: $id, name: $name, email: $email, age: $age}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment