2021-03-14 17:15:38 +00:00
|
|
|
import 'package:comunic/helpers/serialization/base_serialization_helper.dart';
|
|
|
|
import 'package:comunic/models/user.dart';
|
|
|
|
|
|
|
|
/// User serialization helper
|
|
|
|
///
|
|
|
|
/// @author Pierre Hubert
|
|
|
|
|
2022-03-10 18:39:57 +00:00
|
|
|
UsersListSerialisationHelper? _singleton;
|
2021-03-14 17:15:38 +00:00
|
|
|
|
|
|
|
class UsersListSerialisationHelper extends BaseSerializationHelper<User> {
|
|
|
|
UsersListSerialisationHelper._();
|
|
|
|
|
|
|
|
factory UsersListSerialisationHelper() {
|
|
|
|
if (_singleton == null) _singleton = UsersListSerialisationHelper._();
|
|
|
|
|
2022-03-10 18:39:57 +00:00
|
|
|
return _singleton!;
|
2021-03-14 17:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get type => "users-list";
|
|
|
|
|
|
|
|
@override
|
|
|
|
User parse(Map<String, dynamic> m) => User.fromJson(m);
|
|
|
|
|
|
|
|
/// Remove a user by its ID
|
2022-03-10 18:39:57 +00:00
|
|
|
Future<void> removeUserByID(int? userID) =>
|
2021-03-14 17:15:38 +00:00
|
|
|
removeElement((t) => t.id == userID);
|
|
|
|
}
|