dreampad/lib/app/models/user_model.dart
2023-11-28 10:45:09 +08:00

58 lines
1.2 KiB
Dart

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;
}
}