Find the right miniriverpod API

Look up the types and methods in miniriverpod_core.dart and miniriverpod_flutter.dart.

Types for providers and state

These types are the building blocks for providers and their state.

AsyncValue<T>

AsyncLoading / AsyncData / AsyncError

Provider<T>

A synchronous provider that can use autoDispose

AsyncProvider<T>

An asynchronous provider with a .future selector

Read AsyncValue with Dart patterns

Use a pattern in switch or an is type check to handle each AsyncValue state.

Look up Ref and ProviderContainer methods

Use these methods to read or recalculate state, manage cleanup, and run updates.

Methods by task

read / watch / listen                 Get a provider value and subscribe to changes when needed.
invalidate / refresh / refreshValue    Recalculate state.
onDispose / keepAlive / emit           Coordinate cleanup, retention, and streams.
mutation / mutate / invoke             Run writes you can track.
scope / overrideWithValue              Supply dependencies and replace providers in tests.

Flutter types and methods you'll use often

Look up the ProviderScope and WidgetRef APIs you'll use in your app.

// Scope
ProviderScope(
  child: const App(),
);

// ConsumerWidget
class Header extends ConsumerWidget {
  const Header({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final user = ref.watch(currentUser);
    return Text('$user');
  }
}

// Mutation execution
await ref.invoke(userProvider.rename('Alice'));
If you pass a container with ProviderScope(container: external), call container.dispose() when you're finished with it.
Dispose of the container yourself when you use UncontrolledProviderScope.
Use Consumer, ConsumerWidget, or ConsumerStatefulWidget to get a WidgetRef.

Where to go next

Read provider state

See examples of reading Provider and AsyncProvider values.

Learn to read provider state

Run mutations

Define writes and choose what happens when two calls overlap.

Learn to run mutations