Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RandomUser {
- List<Results> users;
- RandomUser({this.users});
- RandomUser.fromJson(Map<String, dynamic> json) {
- if (json['results'] != null) {
- users = new List<Results>();
- json['results'].forEach((v) {
- users.add(new Results.fromJson(v));
- });
- }
- }
- }
- // Results kan ses som user
- class Results {
- Name name;
- Location location;
- Picture picture;
- Results({this.name, this.location, this.picture});
- Results.fromJson(Map<String, dynamic> json) {
- name = json['name'] != null ? new Name.fromJson(json['name']) : null;
- location = json['location'] != null
- ? new Location.fromJson(json['location'])
- : null;
- picture =
- json['picture'] != null ? new Picture.fromJson(json['picture']) : null;
- }
- }
- class Name {
- String title;
- String first;
- String last;
- Name({this.title, this.first, this.last});
- String fullName(){
- String s = this.first + " " + this.last;
- return s;
- }
- Name.fromJson(Map<String, dynamic> json) {
- title = json['title'];
- first = json['first'];
- last = json['last'];
- }
- }
- class Location {
- Street street;
- Location(
- {this.street});
- Location.fromJson(Map<String, dynamic> json) {
- street =
- json['street'] != null ? new Street.fromJson(json['street']) : null;
- }
- String adr(){
- return this.street.name + " " + this.street.number.toString();
- }
- }
- class Street {
- int number;
- String name;
- Street({this.number, this.name});
- Street.fromJson(Map<String, dynamic> json) {
- number = json['number'];
- name = json['name'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['number'] = this.number;
- data['name'] = this.name;
- return data;
- }
- }
- class Picture {
- String large;
- String medium;
- String thumbnail;
- Picture({this.large, this.medium, this.thumbnail});
- Picture.fromJson(Map<String, dynamic> json) {
- large = json['large'];
- medium = json['medium'];
- thumbnail = json['thumbnail'];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement