API ????
This page summarizes commonly used classes ? methods ?? miniriverpod_core.dart ? miniriverpod_flutter.dart.
?? ??
?? state ? provider primitives.
AsyncValue<T>
AsyncLoading / AsyncData / AsyncError
Provider<T>
Synchronous provider ?? optional autoDispose
AsyncProvider<T>
Asynchronous provider ?? .future selector
Reading tip
AsyncValue does not include a when method; use switch pattern matching ?? is checks.
Ref ? ProviderContainer Methods
Common operational methods ? refresh, invalidation, lifecycle, ? mutation execution.
?? ?? ??
ref.invalidate(provider, keepPrevious: true);
??? ?
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 ?? ? 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, ? ConsumerStatefulWidget are all supported.