Files
2026-03-26 22:46:03 +01:00

48 lines
967 B
Dart

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