Referencia API

This page summarizes commonly used classes y methods de miniriverpod_core.dart y miniriverpod_flutter.dart.

Tipos principales

n?cleo state y provider primitives.

AsyncValue<T>

AsyncLoading / AsyncData / AsyncError

Provider<T>

Synchronous provider con optional autoDispose

AsyncProvider<T>

Asynchronous provider con .future selector

Reading tip

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

Ref y ProviderContainer Methods

Common operational methods para refresh, invalidation, lifecycle, y mutation execution.

Secuencia com?n

ref.invalidate(provider, keepPrevious: true);

Mapa de m?todos

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 en 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, y ConsumerStatefulWidget are all supported.

Siguientes pasos

Providers

Return a practical uso de Provider, AsyncProvider, y read APIs.

Open providers

Mutations

Implement explicit write flows con concurrency control.

Open mutaciones