Pod
⚠️ Status: Experimental
A dependency injection and state management library, fast, simple and composable.
Inspired by Riverpod and Jōtai
Package | Pub |
---|---|
pod | |
flutter_pod | |
bloc_pod |
Quick Start
import 'package:pod/pod.dart';
void main() {
// Create a state pod.
final counterPod = statePod(0);
// Create a derived Pod.
final counterTimesTwoPod = pod((ref) => ref.watch(counterPod) * 2);
// Create a pod container.
final container = PodContainer();
// Print derived pod's value.
print(container.get(counterTimesTwoPod)); // 0
// Subscribe derived pod's value changes.
final cancelSubscribe = container.subscribe(counterTimesTwoPod, (value) {
print(value); // 4
});
// Set the value of counter pod to 2.
container.set(counterPod, 2);
// Cancel derived pod's subscribe.
cancelSubscribe();
}