Use familiar Flutter providers with clear state updates

If you've used Provider or AsyncProvider in Riverpod, miniriverpod will feel familiar. Identify instances with a subclass and args, and track updates with a mutation token. The API also makes it clear when provider state is disposed.

Define providers in ordinary Dart

Use a subclass, its args, and a Scope to model a family, override a provider, or pass dependencies. Write them directly in Dart.

Handle async state in one place

Use AsyncProvider for Future and Stream values. It handles cancellation when you rebuild, invalidate, refresh, or dispose of a provider.

Decide how overlapping updates run

Run updates through ref.invoke(provider.method()) and choose what happens when calls overlap with concurrent, queue, restart, or dropLatest.

Set up the scope and make an update

Wrap the app in ProviderScope and define your Provider and AsyncProvider classes. Run changes with ref.invoke and choose a policy for overlapping calls.

Add the package

flutter pub add miniriverpod

Run a mutation

lib/main.dart
class UserProvider extends AsyncProvider<User?> {
  UserProvider() : super.args(null);

  @override
  Future<User?> build(Ref<AsyncValue<User?>> ref) async {
    return ref.watch(apiProvider).me();
  }

  late final renameMut = mutation<void>(#rename);

  Call<void, AsyncValue<User?>> rename(String name) => mutate(
    renameMut,
    (ref) async {
      final api = ref.watch(apiProvider);
      await api.rename(name);
      ref.state = AsyncData(await api.me());
    },
    concurrency: Concurrency.restart,
  );
}

final userProvider = UserProvider();

Future<void> renameUser(WidgetRef ref) async {
  await ref.invoke(userProvider.rename('Alice'));
}
What to expect if you've used Riverpod

You'll recognize Provider + AsyncProvider + WidgetRef from Riverpod. miniriverpod uses subclasses with args, Scope for dependencies, and explicit calls for mutations.