Quick API lookup for daily work.

This page summarizes commonly used classes and methods from miniriverpod_core.dart and miniriverpod_flutter.dart.

Core Types

Core state and provider primitives.

AsyncValue<T>

AsyncLoading / AsyncData / AsyncError

Provider<T>

Synchronous provider with optional autoDispose

AsyncProvider<T>

Asynchronous provider with .future selector

Reading tip

AsyncValue does not include a when method; use switch pattern matching or is checks.

Ref and ProviderContainer Methods

Common operational methods for refresh, invalidation, lifecycle, and mutation execution.

Common sequence

ref.invalidate(provider, keepPrevious: true);

Method map

read / watch / listen                 : read and subscribe to providers.
invalidate / refresh / refreshValue    : recompute state.
onDispose / keepAlive / emit           : lifecycle and stream wiring.
mutation / mutate / invoke             : tracked write operations.
scope / overrideWithValue              : DI and testing overrides.

Flutter API Snapshot

ProviderScope + WidgetRef entry points used in app code.

flutter_usage.dart
// 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'));
ProviderScope(container: external) requires manual container.dispose().
UncontrolledProviderScope never disposes injected container.
Consumer, ConsumerWidget, and ConsumerStatefulWidget are all supported.

Langkah Selanjutnya

Providers

Return to practical usage of Provider, AsyncProvider, and read APIs.

Buka GitHub

ProviderScope

Implement explicit write flows with concurrency control.

Open Mutations