piper_state 0.0.3
piper_state: ^0.0.3 copied to clipboard
Simple Flutter state management with lifecycle-aware ViewModels. Automatic cleanup, explicit dependencies, no boilerplate.
Piper State #
Flutter state management with lifecycle-aware ViewModels.
- ✅ Automatic cleanup — streams cancel, tasks abort
- ✅ Explicit dependencies — constructor injection
- ✅ Zero boilerplate — no code generation
- ✅ Testable — plain Dart classes
Installation #
dependencies:
piper_state: ^0.0.2
flutter_piper: ^0.0.2 # Flutter widgets
Quick Example #
class CounterViewModel extends ViewModel {
late final count = state(0);
void increment() => count.update((c) => c + 1);
}
// In your widget
vm.count.build((count) => Text('$count'));
Stream Binding #
class AuthViewModel extends ViewModel {
final AuthRepository _auth;
AuthViewModel(this._auth);
late final user = bind(_auth.userStream, initial: null);
}
Async Operations #
late final profile = asyncState<Profile>();
void load() => load(profile, () => _repo.fetchProfile());
Why Piper? #
| Piper | Riverpod | Bloc | |
|---|---|---|---|
| No codegen | ✅ | ❌ | ✅ |
| Constructor injection | ✅ | ❌ | ✅ |
| Auto lifecycle | ✅ | ✅ | ❌ |
Documentation #
📖 Full docs · GitHub · flutter_piper
License #
MIT