Initial commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'user.dart';
|
||||
|
||||
class Group extends Equatable {
|
||||
final String id;
|
||||
final String name;
|
||||
final List<User> members;
|
||||
|
||||
const Group({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.members,
|
||||
});
|
||||
|
||||
factory Group.fromJson(Map<String, dynamic> json) {
|
||||
return Group(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
members: (json['members'] as List)
|
||||
.map((m) => User.fromJson(m as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'members': members.map((m) => m.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
Group copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
List<User>? members,
|
||||
}) {
|
||||
return Group(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
members: members ?? this.members,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, name, members];
|
||||
}
|
||||
Reference in New Issue
Block a user