Skip to content

Instantly share code, notes, and snippets.

@teerasej
Created January 16, 2022 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teerasej/3f937f47bada4186b203939857c9085c to your computer and use it in GitHub Desktop.
Save teerasej/3f937f47bada4186b203939857c9085c to your computer and use it in GitHub Desktop.
Good guideline to convert JSON (map) to instance of a class in Flutter/Dart app
class AnnouncementMessage {
String? auctionSequenceId;
String? annoucementText;
AnnouncementMessage({this.auctionSequenceId, this.annoucementText});
static AnnouncementMessage fromMap(Map<String, dynamic> json) {
return AnnouncementMessage.fromJson(json);
}
factory AnnouncementMessage.fromJson(Map<String, dynamic> json) {
return AnnouncementMessage(
auctionSequenceId: json['auction_sequence_id'],
annoucementText: json["annoucement_text"],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment