45 lines
1.1 KiB
Dart
45 lines
1.1 KiB
Dart
class User {
|
|
final String id;
|
|
final String phone;
|
|
final String nickname;
|
|
final String? email;
|
|
final List<String> familyIds;
|
|
final String? activeFamilyId;
|
|
final String joinDate;
|
|
final String createdAt;
|
|
|
|
const User({
|
|
required this.id,
|
|
required this.phone,
|
|
required this.nickname,
|
|
this.email,
|
|
this.familyIds = const [],
|
|
this.activeFamilyId,
|
|
this.joinDate = '',
|
|
this.createdAt = '',
|
|
});
|
|
|
|
factory User.fromJson(Map<String, dynamic> json) {
|
|
return User(
|
|
id: json['id'] as String? ?? '',
|
|
phone: json['phone'] as String? ?? '',
|
|
nickname: json['nickname'] as String? ?? '',
|
|
email: json['email'] as String?,
|
|
familyIds: (json['familyIds'] as List<dynamic>?)?.cast<String>() ?? [],
|
|
activeFamilyId: json['activeFamilyId'] as String?,
|
|
joinDate: json['joinDate'] as String? ?? '',
|
|
createdAt: json['createdAt'] as String? ?? '',
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'phone': phone,
|
|
'nickname': nickname,
|
|
'email': email,
|
|
'familyIds': familyIds,
|
|
'activeFamilyId': activeFamilyId,
|
|
'joinDate': joinDate,
|
|
'createdAt': createdAt,
|
|
};
|
|
} |