Last active
September 7, 2019 18:20
-
-
Save angebagui/5cae42a8ec903102f46bb8659d049d41 to your computer and use it in GitHub Desktop.
ContactResult.dart
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
import 'package:socialapp/model/Contact.dart'; | |
class ContactResult{ | |
bool success; | |
List<Contact> data; | |
String message; | |
ContactResult({this.success, this.data, this.message}); | |
factory ContactResult.fromJson(Map<String, dynamic> json) => ContactResult( | |
success: json['success'] as bool, | |
data: getDataToList(json['data'] as List), | |
message: json['message'] as String | |
); | |
static List<Contact> getDataToList(List<dynamic> json){ | |
if(json != null){ | |
return json.map((e){ | |
if(e != null){ | |
return Contact.fromJson(e); | |
}else{ | |
return null; | |
} | |
}).toList(); | |
}else{ | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment