Ref 02

Provider Decision Guide

Calculating reading time... β€’ Module 1.5: Master Reference

πŸ—ΊοΈ Rapid Provider Selection Engine

Use this multi-tier visual decision tree to select the precise @riverpod provider annotation and signature for any feature in seconds.

1. Master Decision Tree

Step 1: Is your state Asynchronous (Future/Stream) or Synchronous?
ASYNC (Network / DB)
Step 2: Do users perform mutations (POST/PUT)?
  • YES (Mutations + Async): Use @riverpod class X extends _$X (AsyncNotifier)
  • NO (Read-only Future): Use @riverpod Future<T> fn(Ref ref)
  • NO (Realtime Stream): Use @riverpod Stream<T> fn(Ref ref)
SYNCHRONOUS
Step 2: Does state update via user actions?
  • YES (Mutations + Sync): Use @riverpod class X extends _$X (Notifier)
  • NO (Read-only Service/DI): Use @riverpod T fn(Ref ref) (Pure Provider)

2. Real Feature Scenario Mapping

Production Feature Requirement Exact @riverpod Annotation Generated Type
Injecting Dio ApiClient instance @riverpod
Dio dioClient(Ref ref)
AutoDisposeProvider<Dio>
Listening to Firebase Auth user stream @riverpod
Stream<User?> authState(Ref ref)
AutoDisposeStreamProvider<User?>
Fetching backend profile with refresh() mutation @riverpod
class CurrentUserNotifier extends _$CurrentUserNotifier
AutoDisposeAsyncNotifierProvider
Fetching item detail by ID parameter @riverpod
Future<Item> itemDetail(Ref ref, String id)
AutoDisposeFutureProviderFamily