Skip to content

Instantly share code, notes, and snippets.

@rodolfofranco
Created May 24, 2020 00:02
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 rodolfofranco/b55650ae7d548b808ed63b3c8143fae0 to your computer and use it in GitHub Desktop.
Save rodolfofranco/b55650ae7d548b808ed63b3c8143fae0 to your computer and use it in GitHub Desktop.
class Country {
final String name;
final String capital;
Country({this.name, this.capital});
Map<String, dynamic> toJson() => {'name': name, 'capital': capital};
factory Country.fromMap(Map data) {
data = data ?? {};
return Country(
name: data['name'] ?? null, capital: data['capital'] ?? null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment