0 purchases
stately riverpod
Stately #
A simple FSM solution for creating declarative and predictable state machines.
Designed to work with popular state management solutions to no matter what you are using you
should be able to drop this right in!
stately_core
stately_bloc
stately_notifier
stately_riverpod
To get started, you can utilize stately_notifier without any extra dependencies like so:
class CounterEvent {
const CounterEvent(this.value);
final int value;
}
class CounterValueNotifier extends StatelyChangeNotifier<CounterEvent, int> {
CounterValueNotifier(super.state);
@override
StatelyGraph<CounterEvent, int> get graph => StatelyGraph<ExampleEvent, String>(
graph: {
String: {
ExampleEvent: transition((CounterEvent event, int state) => event.value),
},
},
);
}
copied to clipboard
And then can use it with ValueListenableBuilder like so:
final counter = CounterValueNotifier(0);
/// ...
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
ValueListenableBuilder(
valueListenable: counter,
builder: (ctx, state, child) {
return Text(state.toString(), style: Theme.of(context).textTheme.headlineMedium);
},
),
ElevatedButton(onPressed: () => notifier.add(IncrementEvent()), child: Text('Increment')),
],
);
}
}
copied to clipboard
That's it!
Examples #
The examples are a great way to see how to utilize this package with a variety of state management solutions.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.