selfprivacy.org.app/lib/logic/cubit/users/users_state.dart

28 lines
737 B
Dart
Raw Normal View History

2020-12-03 18:52:53 +02:00
part of 'users_cubit.dart';
class UsersState extends ServerInstallationDependendState {
const UsersState(this.users);
2020-12-03 18:52:53 +02:00
final List<User> users;
User get rootUser => users.firstWhere((final user) => user.type == UserType.root);
User get primaryUser => users.firstWhere((final user) => user.type == UserType.primary);
List<User> get normalUsers => users.where((final user) => user.type == UserType.normal).toList();
2020-12-03 18:52:53 +02:00
@override
List<Object> get props => [users];
UsersState copyWith({
2022-06-05 22:36:32 +03:00
final List<User>? users,
}) =>
UsersState(
users ?? this.users,
);
2021-01-06 19:35:57 +02:00
bool isLoginRegistered(final String login) => users.any((final User user) => user.login == login);
2021-01-06 19:35:57 +02:00
bool get isEmpty => users.isEmpty;
2020-12-03 18:52:53 +02:00
}