Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. class RandomUser {
  2. List<Results> users;
  3.  
  4. RandomUser({this.users});
  5.  
  6. RandomUser.fromJson(Map<String, dynamic> json) {
  7. if (json['results'] != null) {
  8. users = new List<Results>();
  9. json['results'].forEach((v) {
  10. users.add(new Results.fromJson(v));
  11. });
  12. }
  13. }
  14. }
  15.  
  16. // Results kan ses som user
  17. class Results {
  18. Name name;
  19. Location location;
  20. Picture picture;
  21.  
  22. Results({this.name, this.location, this.picture});
  23.  
  24. Results.fromJson(Map<String, dynamic> json) {
  25. name = json['name'] != null ? new Name.fromJson(json['name']) : null;
  26. location = json['location'] != null
  27. ? new Location.fromJson(json['location'])
  28. : null;
  29. picture =
  30. json['picture'] != null ? new Picture.fromJson(json['picture']) : null;
  31. }
  32. }
  33.  
  34. class Name {
  35. String title;
  36. String first;
  37. String last;
  38.  
  39. Name({this.title, this.first, this.last});
  40.  
  41. String fullName(){
  42. String s = this.first + " " + this.last;
  43. return s;
  44. }
  45.  
  46. Name.fromJson(Map<String, dynamic> json) {
  47. title = json['title'];
  48. first = json['first'];
  49. last = json['last'];
  50. }
  51. }
  52.  
  53. class Location {
  54. Street street;
  55. Location(
  56. {this.street});
  57.  
  58. Location.fromJson(Map<String, dynamic> json) {
  59. street =
  60. json['street'] != null ? new Street.fromJson(json['street']) : null;
  61. }
  62.  
  63. String adr(){
  64. return this.street.name + " " + this.street.number.toString();
  65. }
  66. }
  67.  
  68. class Street {
  69. int number;
  70. String name;
  71.  
  72. Street({this.number, this.name});
  73.  
  74. Street.fromJson(Map<String, dynamic> json) {
  75. number = json['number'];
  76. name = json['name'];
  77. }
  78.  
  79. Map<String, dynamic> toJson() {
  80. final Map<String, dynamic> data = new Map<String, dynamic>();
  81. data['number'] = this.number;
  82. data['name'] = this.name;
  83. return data;
  84. }
  85. }
  86.  
  87. class Picture {
  88. String large;
  89. String medium;
  90. String thumbnail;
  91.  
  92. Picture({this.large, this.medium, this.thumbnail});
  93.  
  94. Picture.fromJson(Map<String, dynamic> json) {
  95. large = json['large'];
  96. medium = json['medium'];
  97. thumbnail = json['thumbnail'];
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement