If you want to implement inheritance in dart? You need to check out dart syntax which is a bit different from languages like C# using : for inheritance.
This is how you do it on your own:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | class Photo { final String id; final String owner, server, secret, title; final int farm, isfamily, ispublic, isfriend; final String url; Photo( {this.id, this.owner, this.secret, this.server, this.farm, this.title, this.ispublic, this.isfriend, this.isfamily, this.url}); factory Photo.fromJson(Map<String, dynamic> parsedJson) { return new Photo( id: parsedJson['id'], owner: parsedJson['owner'], secret: parsedJson['secret'], server: parsedJson['server'], farm: parsedJson['farm'], title: parsedJson['title'], ispublic: parsedJson['ispublic'], isfriend: parsedJson['isfriend'], isfamily: parsedJson['isfamily'], url: parsedJson['url_m']); } } class gPhoto extends Photo { final String ownername; final String dateadded; gPhoto( {id, owner, secret, server, farm, title, ispublic, isfriend, isfamily, url, this.ownername, this.dateadded}) : super( id: id, owner: owner, secret: secret, server: server, farm: farm, title: title, ispublic: ispublic, isfamily: isfamily, url: url); factory gPhoto.fromJson(Map<String, dynamic> parsedJson) { final photo = Photo.fromJson(parsedJson); final ownername = parsedJson['ownername']; final dateadded = parsedJson['dateadded']; return gPhoto( dateadded: dateadded, ownername: ownername, farm: photo.farm, id: photo.id, isfamily: photo.isfamily, isfriend: photo.isfriend, ispublic: photo.ispublic, owner: photo.owner, secret: photo.secret, server: photo.server, title: photo.title, url: photo.url, ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.