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 navigation events 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) or context.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 previous state and the current state and is responsible for returning a bool which determines whether to rebuild StateObserver with the current state.
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 the BuildContext and state and is responsible for returning a widget which is to be rendered.