BitControl<M, V, L> class
a class that helps you manage the state of a bit. It has a generic
type L
that represents the loading state of the bit. You can use
MsgBitControl
if you want to use a string as the loading state.
You can also use SimpleBit
for more simple cases.
Constructors
-
BitControl.new(Bit<
V, L> _bit, {M map(V value, M? previous)?, M? initial, bool lazy = true, bool history = true}) -
BitControl.worker(BitWorker<
V, L> worker, {M? initial, bool lazy = true, bool history = true})
Properties
Methods
-
act(
FutureOr< M> onData(M data), {bool silent = true}) → void -
this method allows you to easily mutate the state of the bit
it is a shorthand for the
state.whenOrNull
method. It will call theonData
function and emit the result of the function if it does not throw an error otherwise it will emit an error state. -
back(
) → void -
Emits the previous state, if
history
is enabled. otherwise, it does nothing. -
backIsPossible(
) → bool - Returns true if the history is not empty. This means that the back method will have an effect.
-
dispose(
) → void -
effect(
BitState< M, L> state) → void - Gets called whenever the state of the bit changes.
-
emit(
M data) → void -
emitError(
dynamic e) → void -
emitLoading(
[L? loading]) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onStateChange(
) → void -
reload(
{bool silent = false}) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
maybeOf<
B extends BitControl> (BuildContext context) → B? -
of<
B extends BitControl> (BuildContext context) → B