54 lines
1.1 KiB
Dart
54 lines
1.1 KiB
Dart
import 'group_member.dart';
|
|
|
|
class Account {
|
|
final String id;
|
|
final String tripId;
|
|
final String groupId;
|
|
final String name;
|
|
final List<GroupMember> members;
|
|
|
|
Account({
|
|
required this.id,
|
|
required this.tripId,
|
|
required this.groupId,
|
|
required this.name,
|
|
List<GroupMember>? members,
|
|
}) : members = members ?? [];
|
|
|
|
|
|
factory Account.fromMap(Map<String, dynamic> map) {
|
|
return Account(
|
|
id: map['id'] as String,
|
|
tripId: map['tripId'] as String,
|
|
groupId: map['groupId'] as String,
|
|
name: map['name'] as String,
|
|
members: [],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'tripId': tripId,
|
|
'groupId': groupId,
|
|
'name': name,
|
|
'members': members.map((member) => member.toMap()).toList(),
|
|
};
|
|
}
|
|
|
|
Account copyWith({
|
|
String? id,
|
|
String? tripId,
|
|
String? groupId,
|
|
String? name,
|
|
List<GroupMember>? members,
|
|
}) {
|
|
return Account(
|
|
id: id ?? this.id,
|
|
tripId: tripId ?? this.tripId,
|
|
groupId: groupId ?? this.groupId,
|
|
name: name ?? this.name,
|
|
members: members ?? this.members,
|
|
);
|
|
}
|
|
} |