flutter_onlooker library
A state management library that provides a simple solution for updating state and navigation.
Classes
- Takes routeName, arguments, and resultConsumer which are responsible for navigation from the StateNotifier and getting result directly to it.
-
Provider<
N extends StateNotifier> - A generic implementation of InheritedWidget that allows to obtain StateNotifier using Provider.of for any descendant of this widget.
- StateNotifier
-
This class provides mechanism of delivering new UI
states
and navigationevents
to widgets. Widgets should use getStateStream and getNavigationStream to observe on StateNotifier events. -
StateNotifierProvider<
N extends StateNotifier> -
Takes a Create function that is responsible for creating
the StateNotifier, child which will have access to the instance via
Provider.of<StateNotifier>(context)
orcontext.read<StateNotifier>()
and optional router function that will receive navigation events. -
StateObserver<
N extends StateNotifier, S> -
StateObserver rebuilds using builder function in response
to new
states
.
Extensions
- ReadContext on BuildContext
- Exposes the read method.
Typedefs
-
BuilderCondition<
S> = bool Function(S previous, S current) -
Signature for the
buildWhen
function which takes the previousstate
and the currentstate
and is responsible for returning a bool which determines whether to rebuild StateObserver with the currentstate
. -
Create<
T> = T Function(BuildContext context) -
A function that creates an object of type
T
. - ResultConsumer = void Function(Future?)
- A callback function that is used to return navigation result to the StateNotifier.
- Router = Future? Function(BuildContext context, String routeName, Object? arguments)
-
A function that listens for navigation events.
Return navigation
result
from this function to get that in StateNotifier. -
WidgetBuilder<
S> = Widget Function(BuildContext context, S state) -
Signature for the
builder
function which takes theBuildContext
andstate
and is responsible for returning a widget which is to be rendered.