Shard is a lightweight, powerful state management solution for Flutter that feels natural and requires minimal boilerplate. Built on Flutter's ChangeNotifier, Shard gives you a simple API to manage state—from simple counters to async operations with optional caching and persistence.
You get a lot without extra packages: intuitive methods like emit() and onChange(), built-in persistence for saving state across app restarts, response caching for FutureShard, and debounce/throttle for performance. Everything is type-safe and testable, with clear separation of concerns.
| Feature | Description |
|---|---|
| Simple API | Intuitive methods like emit(), onChange(), onInit() |
| Persistence | Automatic state persistence with customizable storage |
| Caching | Built-in response caching for FutureShard - zero config |
| Async Support | FutureShard and StreamShard for async operations |
| Debounce/Throttle | Built-in mixins to optimize performance |
| Observers | Global state monitoring and error handling |
| Widgets | ShardBuilder, ShardSelector, AsyncShardBuilder |
| Lightweight | Minimal dependencies, no code generation |
| Commands | CommandShard for one-shot async actions (submit, create/update/delete) |
| Derived state | ComputedShard recomputes from other shards or listenables |
| Undo / Redo | HistoryMixin adds undo/redo to any shard |
| Listeners | ShardListener for side effects without rebuilding |
| Testing | ShardTester, fakes, and a mock observer in package:shard/shard_test.dart |
| Logging | LoggingObserver logs to DevTools, inert in release |
Get started in two steps: Installation to add Shard to your project, then Quick Start to build your first shard. After that, follow Core Concepts, All Shards, and Examples in order.