Files
flutter-go/lib/model/user_info.dart
2019-07-22 17:09:01 +08:00

33 lines
712 B
Dart

class UserInformation {
String username;
int id;
String avatarPic;
String themeColor;
UserInformation({
this.avatarPic,
this.id,
this.themeColor,
this.username,
});
factory UserInformation.fromJson(Map<String, dynamic> json) {
print('fromJOSN $json ${json['id'].runtimeType}');
String name = json['name'];
int userId ;
if(json['name'] == null){
name = json['url_name'];
}
if(json['id'].runtimeType == int){
userId = json['id'];
}else{
userId = int.parse(json['id']);
}
return UserInformation(
avatarPic: json['avatar_pic'],
id: userId,
username: name,
themeColor: json['theme_color']);
}
}