dreampad/lib/app/models/user_model.dart

58 lines
1.2 KiB
Dart
Raw Permalink Normal View History

2023-11-28 10:44:58 +08:00
class User {
AccountInfo? accountInfo;
User({
this.accountInfo,
});
User.fromJson(Map<String, dynamic> json) {
accountInfo = AccountInfo?.fromJson(json['accountInfo']);
}
}
class AccountInfo {
String? id;
String? userName;
String? avatarUrl;
String? phoneNumber;
AccountInfo({
this.id,
this.userName,
this.avatarUrl,
this.phoneNumber,
});
AccountInfo.fromJson(Map<String, dynamic> json) {
id = json['id'].toString();
userName = json['userName'];
avatarUrl = json['avatarUrl'];
phoneNumber = json['phoneNumber'];
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['id'] = id;
data['userName'] = userName;
data['avatarUrl'] = avatarUrl;
data['phoneNumber'] = phoneNumber;
return data;
}
AccountInfo.fromMap(Map<dynamic, dynamic> map) {
id = map['id'];
userName = map['userName'];
avatarUrl = map['avatarUrl'];
phoneNumber = map['phoneNumber'];
}
Map<String, dynamic> toMap() {
Map<String, dynamic> map = {
'id': id,
'userName': userName,
'avatarUrl': avatarUrl,
'phoneNumber': phoneNumber,
};
return map;
}
}