53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
class FamilyMember {
|
|
final String userId;
|
|
final String nickname;
|
|
final String role;
|
|
final String joinedAt;
|
|
|
|
const FamilyMember({
|
|
required this.userId,
|
|
required this.nickname,
|
|
this.role = 'member',
|
|
this.joinedAt = '',
|
|
});
|
|
|
|
factory FamilyMember.fromJson(Map<String, dynamic> json) {
|
|
return FamilyMember(
|
|
userId: json['userId'] as String? ?? '',
|
|
nickname: json['nickname'] as String? ?? '',
|
|
role: json['role'] as String? ?? 'member',
|
|
joinedAt: json['joinedAt'] as String? ?? '',
|
|
);
|
|
}
|
|
}
|
|
|
|
class Family {
|
|
final String id;
|
|
final String name;
|
|
final String inviteCode;
|
|
final String createdBy;
|
|
final String createdAt;
|
|
final List<FamilyMember> members;
|
|
|
|
const Family({
|
|
required this.id,
|
|
required this.name,
|
|
required this.inviteCode,
|
|
this.createdBy = '',
|
|
this.createdAt = '',
|
|
this.members = const [],
|
|
});
|
|
|
|
factory Family.fromJson(Map<String, dynamic> json) {
|
|
return Family(
|
|
id: json['id'] as String? ?? '',
|
|
name: json['name'] as String? ?? '',
|
|
inviteCode: json['inviteCode'] as String? ?? '',
|
|
createdBy: json['createdBy'] as String? ?? '',
|
|
createdAt: json['createdAt'] as String? ?? '',
|
|
members: (json['members'] as List<dynamic>?)
|
|
?.map((m) => FamilyMember.fromJson(m as Map<String, dynamic>))
|
|
.toList() ?? [],
|
|
);
|
|
}
|
|
} |