-
-
Save red-star25/e1252565070a23f3cc4d042f46b32679 to your computer and use it in GitHub Desktop.
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
JokeModel jokeModelFromJson(String str) => JokeModel.fromJson(json.decode(str)); | |
String jokeModelToJson(JokeModel data) => json.encode(data.toJson()); | |
class JokeModel { | |
JokeModel({ | |
required this.setup, | |
required this.delivery, | |
required this.id, | |
}); | |
String setup; | |
String delivery; | |
int id; | |
factory JokeModel.fromJson(Map<String, dynamic> json) => JokeModel( | |
setup: json["setup"] ?? json["joke"], | |
delivery: json["delivery"] ?? "", | |
id: json["id"], | |
); | |
Map<String, dynamic> toJson() => { | |
"setup": setup, | |
"delivery": delivery, | |
"id": id, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment