ReactterHook class abstract
An abstract-class that provides the functionality of ReactterState.
This is an example of how to create a custom hook:
class UseToggle extends ReactterHook {
final $ = ReactterHook.$register;
final _state = UseState(false);
bool get value => _state.value;
UseToggle(bool initial) {
_state.value = initial;
}
void toggle() => _state.value = !_state.value;
}
IMPORTANT: All ReactterHook must be registered using the final $ variable.:
and use it, like so:
class AppController { final state = UseToggle(false); UserContext() { print('initial value: ${state.value}'); state.toggle(); print('toggle value: ${state.value}'); } }
See also:
- ReactterState, adds state management features to ReactterHook.
- Implemented types
- Implementers
Constructors
Properties
- $ → _ReactterHookRegister
-
This variable is used to register ReactterHook
and attach the ReactterState that are defined here.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- instanceAttached → Object?
-
no setterinherited
- isDisposed → bool
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
attachTo(
Object instance) → void -
Attaches an object instance to this state.
inherited
-
detachInstance(
) → void -
Detaches an object instance to this state.
inherited
-
dispose(
) → void -
Called when this object is removed
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → void -
It's used to notify listeners that the state has been updated.
It is typically called after making changes to the state object.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
[covariant Function? callback]) → void -
Executes
callback
, and notify the listeners about to update.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- $register → _ReactterHookRegister
-
This getter allows access to the
_ReactterHookRegister
instance which is responsible for registering a ReactterHook and attaching previously collected states to it.no setter