Bloc<S> class Null safety

The central class behind this library

It is responsible for processing all the events and broadcasting corresponding changes made to the state. R is the type which subclasses Bloc S is the type of value which this bloc broadcasts. S must implement equality

Implementers

Constructors

Bloc({S? initialState, BlocMonitor monitor = const BlocEventsPrinter()})
initialState is the state which is set at initialization. if its null, the initial state is set to busy.

Properties

error StateError
read-only
hasError bool
read-only
hashCode int
The hash code for this object.
read-onlyinherited
isBusy bool
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
state → S
read-only
stream Stream<S?>
Broadcast Stream to which all builders listen
read-only

Methods

dispose() Future<void>
Send a done event and disposes the stream
nextState(S? currentState, S update) → S?
Called to calculate the new state
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
refresh() → void
Broadcasts the same state
setBusy({String? event}) → void
Called by blocs (subclasses) when the updated state isn't available immediately
setError(StateError error, {String? event}) → void
Called by blocs (subclasses) when an error occurs
setState(S update, {String? event}) → void
Called by blocs (subclasses) when the state is updated
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

checkIfValueType bool
read / write