1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 14:29:22 +00:00
comunicmobile/lib/helpers/serialization/user_list_serialization_helper.dart

29 lines
725 B
Dart
Raw Normal View History

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
UsersListSerialisationHelper _singleton;
class UsersListSerialisationHelper extends BaseSerializationHelper<User> {
UsersListSerialisationHelper._();
factory UsersListSerialisationHelper() {
if (_singleton == null) _singleton = UsersListSerialisationHelper._();
return _singleton;
}
@override
String get type => "users-list";
@override
User parse(Map<String, dynamic> m) => User.fromJson(m);
/// Remove a user by its ID
Future<void> removeUserByID(int userID) =>
removeElement((t) => t.id == userID);
}