piper_state 0.1.1 copy "piper_state: ^0.1.1" to clipboard
piper_state: ^0.1.1 copied to clipboard

Flutter state management that cleans up after itself. Plain Dart ViewModels, computed state, explicit dependencies, and cooperative task cancellation.

Piper State

Piper State #

pub package likes popularity pub points CI codecov License: MIT Dart style: lints

Flutter state management that cleans up after itself.

  • ✅ Automatic rebuilds — tracked reads, no dependency lists
  • ✅ Lifecycle-owned cleanup — streams and cooperative tasks stop on dispose
  • ✅ Explicit dependencies — constructor injection keeps the graph visible
  • ✅ Plain Dart — no code generation, direct unit tests

Installation #

For Dart-only projects:

dependencies:
  piper_state: ^0.1.0

Flutter apps can install flutter_piper: ^0.1.0 instead; it re-exports this package and adds scopes, builders, and listeners.

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 loadProfile() => load(profile, () => _repo.fetchProfile());

Why Piper? #

Piper Riverpod Bloc
Dependencies constructor ref.watch / ref.read constructor
State changes methods providers + notifiers methods (Cubit) or events (Bloc)
Code generation none optional optional
Testing plain Dart test() ProviderContainer.test() blocTest

Piper favors plain objects over a provider graph or event log. See the full comparison for the trade-offs and async cancellation details.

Documentation #

📖 Full docs · GitHub · flutter_piper

License #

MIT

2
likes
160
points
186
downloads

Documentation

Documentation
API reference

Publisher

verified publisherglennso.dev

Weekly Downloads

Flutter state management that cleans up after itself. Plain Dart ViewModels, computed state, explicit dependencies, and cooperative task cancellation.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#state-management #viewmodel #reactive-programming #dependency-injection #flutter

License

MIT (license)

Dependencies

meta

More

Packages that depend on piper_state