Piper

Piper State

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

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

Libraries

piper_state
A lightweight state management library for Flutter.