Getting Started

Introduction

Learn what Shard is and why you should use it for Flutter state management.

What is Shard?

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.

New in 2.0 — see What's New for the highlights and Migrating from 1.x for the three breaking changes.

Why Choose Shard?

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.

Key Features

FeatureDescription
Simple APIIntuitive methods like emit(), onChange(), onInit()
PersistenceAutomatic state persistence with customizable storage
CachingBuilt-in response caching for FutureShard - zero config
Async SupportFutureShard and StreamShard for async operations
Debounce/ThrottleBuilt-in mixins to optimize performance
ObserversGlobal state monitoring and error handling
WidgetsShardBuilder, ShardSelector, AsyncShardBuilder
LightweightMinimal dependencies, no code generation
CommandsCommandShard for one-shot async actions (submit, create/update/delete)
Derived stateComputedShard recomputes from other shards or listenables
Undo / RedoHistoryMixin adds undo/redo to any shard
ListenersShardListener for side effects without rebuilding
TestingShardTester, fakes, and a mock observer in package:shard/shard_test.dart
LoggingLoggingObserver logs to DevTools, inert in release

Next Steps

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.