selfprivacy.org.app/lib/logic/cubit/providers/providers_state.dart

26 lines
735 B
Dart
Raw Normal View History

2020-12-10 20:33:19 +00:00
part of 'providers_cubit.dart';
class ProvidersState extends Equatable {
const ProvidersState(this.all);
final List<ProviderModel> all;
ProvidersState updateElement(ProviderModel provider, StateType newState) {
var newList = [...all];
var index = newList.indexOf(provider);
newList[index] = provider.updateState(newState);
return ProvidersState(newList);
}
List<ProviderModel> get connected =>
all.where((service) => service.state != StateType.uninitialized).toList();
List<ProviderModel> get uninitialized =>
all.where((service) => service.state == StateType.uninitialized).toList();
bool get isFullyInitialized => uninitialized.isEmpty;
@override
List<Object> get props => all;
}