Bloc<S> class
abstract
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<
Bloc, dynamic> 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
-
no setter
- hasError → bool
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isBusy → bool
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → S?
-
no setter
-
stream
→ Stream<
S?> -
Broadcast Stream to which all builders listen
no setter
Methods
-
addListener(
BlocListener callback) → void - Adds a callback function to the list on active callbacks
-
close(
) → 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 nonexistent method or property is accessed.
inherited
-
refresh(
) → void - Broadcasts the same state
-
removeListener(
BlocListener callback) → void - Removes a callback function from the list
-
setBusy(
{String? event}) → void - Called by blocs (subclasses) when the updated state isn't available immediately
-
setError(
dynamic 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
- callerAsEventName ↔ bool
-
If set to true, the calling function's name will be used as event name,
if event name is not already set.
Library uses StackTrace
_caller
to find name of calling function, and this is not always possible.getter/setter pair - checkIfValueType ↔ bool
-
This library requires the state type to either be a primitive or override == operator.
Set this to false if you manually override ==.
getter/setter pair