stateplus library
StatePlus: A lightweight reactive state management and navigation library for Flutter.
This library provides reactive primitives (Signal, Computed, effect) for building reactive UIs, along with Flutter widgets (StateWidget, StateRouter) and a simple reactive routing solution (RouteState).
Example:
import 'package:stateplus/stateplus.dart';
final count = Signal<int>(0);
StateWidget(
builder: () {
return Text('Count: ${count.value}');
},
);
count.value = 1; // Automatically rebuilds the widget
Classes
-
Computed<
T> - A reactive value that automatically recalculates whenever its dependencies change.
- RouteState
- Manages the current route path as a reactive signal.
-
Signal<
T> - A reactive value that notifies observers when it changes.
- StateRouter
- A widget that renders different UI based on the current route state.
- StateWidget
- A widget that rebuilds itself whenever any reactive dependencies used inside its builder change.
Functions
-
effect(
void fn()) → void -
Runs a side-effect whenever any reactive dependencies used inside
fnchange.