selfprivacy.org.app/lib/logic/cubit/services/services_state.dart

27 lines
666 B
Dart
Raw Normal View History

2020-12-01 19:08:19 +00:00
part of 'services_cubit.dart';
@immutable
2020-12-10 20:33:19 +00:00
class ServicesState extends Equatable{
2020-12-01 19:08:19 +00:00
ServicesState(this.all);
final List<Service> all;
2020-12-10 20:33:19 +00:00
ServicesState updateElement(Service service, StateType newState) {
2020-12-01 19:08:19 +00:00
var newList = [...all];
var index = newList.indexOf(service);
newList[index] = service.updateState(newState);
return ServicesState(newList);
}
List<Service> get connected => all
2020-12-10 20:33:19 +00:00
.where((service) => service.state != StateType.uninitialized)
2020-12-01 19:08:19 +00:00
.toList();
List<Service> get uninitialized => all
2020-12-10 20:33:19 +00:00
.where((service) => service.state == StateType.uninitialized)
2020-12-01 19:08:19 +00:00
.toList();
2020-12-10 20:33:19 +00:00
@override
List<Object> get props => all;
2020-12-01 19:08:19 +00:00
}