Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. class PostList extends ListMapable {
  2. List<PostResponse> posts;
  3.  
  4. @override
  5. Mapable fromJsonList(List json) {
  6. posts = json.map((i) => PostResponse.fromJson(i)).toList();
  7. return this;
  8. }
  9. }
  10.  
  11. class PostResponse {
  12. String userId;
  13. int id;
  14. String title;
  15. String body;
  16.  
  17. PostResponse({
  18. this.userId,
  19. this.id,
  20. this.title,
  21. this.body,
  22. });
  23.  
  24. factory PostResponse.fromJson(Map<String, dynamic> json) {
  25. return new PostResponse(
  26. userId: json['userId'].toString(),
  27. id: json['id'],
  28. title: json['title'],
  29. body: json['body'],
  30. );
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement