registerState<S> method
Registers state of S
type that can be processed by this Bloc.
Creates stream and all necessary resources that need to process state of S
type.
You can pass object that will define initialState
.
Throws StateError if this method was called twice for the same type or if this Bloc was closed.
Throws StateError if this Bloc was disposed.
Implementation
@protected
void registerState<S>({
S? initialState,
}) {
assert(_isNullable<S>() || initialState != null);
if (isDisposed) {
throw StateError(
'This bloc was closed. You can\'t register state for closed bloc');
}
_store[S] = _StateDeliveryController<S>(
initialState: initialState,
);
}