State ManagementIntermediate30 XP4 min read
What are the different provider types in Riverpod?
TL;DR: Riverpod offers Provider (sync read-only), StateProvider (simple mutable state), FutureProvider (async one-shot), StreamProvider (async continuous), and NotifierProvider/AsyncNotifierProvider (complex state with methods).
Full Answer
- ▸Provider<T> — read-only computed value or service; never rebuilds from external triggers
- ▸StateProvider<T> — simple mutable state with ref.read(p.notifier).state = value
- ▸FutureProvider<T> — wraps a Future; exposes AsyncValue<T>
- ▸StreamProvider<T> — wraps a Stream; exposes AsyncValue<T>
- ▸NotifierProvider<N,T> — synchronous Notifier with methods; replaces StateNotifierProvider
- ▸AsyncNotifierProvider<N,T> — asynchronous Notifier; replaces FutureProvider + logic
🎯
In Riverpod 2.x, NotifierProvider and AsyncNotifierProvider are the recommended approach. StateNotifierProvider is legacy. Use @riverpod code generation to reduce boilerplate further.
Code Examples
dartNotifierProvider example
Output
todos list updates reactively; all watchers rebuild when add() or remove() is called
Common Mistakes
- ✗Using StateProvider for complex logic — it only holds a value with no methods
- ✗Mixing Riverpod 1.x StateNotifierProvider with Riverpod 2.x patterns
Interview Tip
💡
Knowing the Riverpod 2.x distinction between NotifierProvider and the legacy StateNotifierProvider signals you're current with the ecosystem.
#Riverpod#FutureProvider#StreamProvider#StateNotifierProvider#NotifierProvider