By Abdelrahman Saed — Senior Mobile Engineer. Last updated: 2026-08-10.
Riverpod is a reactive state management framework for Flutter that resolves the limitations of the Provider package. It provides compile-time safety, eliminates BuildContext dependency for dependency injection, and handles caching and disposal automatically through providers.
Riverpod revolves around providers — declarative descriptions of a piece of state. A provider can be as simple as a value or as complex as an async stream with caching and invalidation.
// A simple provider
final counterProvider = StateProvider<int>((ref) => 0);
// An async provider with caching
final userProfileProvider = FutureProvider.family<User, String>((ref, userId) async {
final repo = ref.watch(userRepositoryProvider);
return repo.fetchUser(userId);
});
The UI consumes providers with ref.watch (rebuilds when the state changes) or ref.read (reads once without rebuilding):
class UserProfileWidget extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final user = ref.watch(userProfileProvider('123'));
return user.when(
data: (u) => Text(u.name),
loading: () => CircularProgressIndicator(),
error: (e, s) => Text('Error: $e'),
);
}
}
Riverpod's key differentiators:
Ref, not context. This means you can access providers in tests, in background isolates, and in non-widget code.autoDispose clean up their resources when no widget is watching them, preventing memory leaks.userProfileProvider per user ID).Choose Riverpod when:
Choose BLoC/Cubit instead when:
Neither is objectively better. Riverpod excels at compile-time safety, caching, and provider composition. BLoC excels at strict event-driven architecture with an audit trail. At iStoria (5M+ users), we use BLoC/Cubit because the event/state pattern scales predictably across 50+ modules with a team of engineers. Many teams successfully use Riverpod at similar scale.
No — you can use Riverpod without code generation using the classic provider syntax. However, the riverpod_generator package provides @riverpod-annotated providers that are more concise and support better analyzer tooling. For apps with more than 20 providers, the generated approach is recommended.
Available for hire. Abdelrahman Saed is a Senior Mobile Engineer (Flutter) — open to full-time, fractional, contract, or advisory work. Hire me →
Book a 20-minute call · Download the CV (PDF) · See how I work