### Provider Definition Example Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Consumer/Consumer.html A basic example of a provider definition using the @riverpod annotation. ```dart @riverpod Future fetchUser(Ref ref) async { // ... } ``` -------------------------------- ### ConsumerWidget Usage Example Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Consumer/Consumer.html An example of using ConsumerWidget, which causes the entire widget to rebuild when the provider changes. ```dart class Example extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return Scaffold( appBar: AppBar(title: Text('User')), body: switch (ref.watch(userProvider) { AsyncValue(:final value?) => Text(value.name), AsyncValue(hasError: true) => Text('Error'), _ => CircularProgressIndicator(), }, } } ``` -------------------------------- ### Define a FutureProvider for configuration Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/FutureProvider/FutureProvider.html Example of using FutureProvider to load and parse a JSON configuration file asynchronously. ```dart final configProvider = FutureProvider((ref) async { final content = json.decode( await rootBundle.loadString('assets/configurations.json'), ) as Map; return Configuration.fromJson(content); }); ``` -------------------------------- ### Implement mutationStart in ProviderObserver Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderObserver/mutationStart.html Override this method to react when a mutation starts. The mutation parameter is guaranteed to be non-null. ```dart void mutationStart( ProviderObserverContext context, Mutation mutation, ) {} ``` -------------------------------- ### Consumer Widget Usage Example Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Consumer/Consumer.html An example of using the Consumer widget to rebuild only a specific part of the widget tree. ```dart class Example extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('User')), body: Consumer( builder: (context, ref, child) { return switch (ref.watch(userProvider) { AsyncValue(:final value?) => Text(value.name), AsyncValue(hasError: true) => Text('Error'), _ => CircularProgressIndicator(), }; }), ); } } ``` -------------------------------- ### Correct Family Usage Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifierProvider/family-constant.html Example of correctly passing a parameter to a family provider. ```dart Widget build(BuildContext context, WidgetRef ref) { final response = ref.watch(messagesFamily('id')); } ``` -------------------------------- ### mutationStart(ProviderObserverContext context, Mutation mutation) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderObserver/mutationStart.html A lifecycle method called when a mutation starts. The mutation parameter is provided as a convenience and is guaranteed to be non-null. ```APIDOC ## mutationStart(ProviderObserverContext context, Mutation mutation) ### Description A lifecycle hook that is invoked when a mutation starts. This method provides access to the current provider observer context and the specific mutation being performed. ### Parameters - **context** (ProviderObserverContext) - The context associated with the provider observer. - **mutation** (Mutation) - The mutation object that has started. This is identical to the mutation found within the context. ``` -------------------------------- ### Implementation of listen method Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderContainer/listen.html The internal implementation of the listen method within ProviderContainer, including parameter validation and subscription setup. ```dart ProviderSubscription listen( ProviderListenable provider, void Function(StateT? previous, StateT next) listener, { bool fireImmediately = false, bool weak = false, void Function(Object error, StackTrace stackTrace)? onError, }) { assert( !(weak && fireImmediately), 'Cannot specify both weak and fireImmediately', ); final sub = provider._addListener( ContainerNode(container: this), listener, weak: weak, onError: onError ?? defaultOnError, onDependencyMayHaveChanged: null, ); _handleFireImmediately(container, sub, fireImmediately: fireImmediately); sub.impl._listenedElement.addDependentSubscription(sub.impl); return sub; } ``` -------------------------------- ### Implement a custom ProviderListenable with SyncProviderTransformerMixin Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/misc/SyncProviderTransformerMixin-mixin.html This example demonstrates creating a 'Where' class that filters provider updates using the mixin, along with an extension to apply it to any ProviderListenable. ```dart final class Where with SyncProviderTransformerMixin { Where(this.source, this.where); @override final ProviderListenable source; final bool Function(T previous, T value) where; @override ProviderTransformer transform( ProviderTransformerContext context, ) { return ProviderTransformer( initState: (_) => context.sourceState.requireValue, listener: (self, previous, next) { if (where(previous, next)) self.state = next; }, ); } } extension on ProviderListenable { ProviderListenable where( bool Function(T previous, T value) where, ) => Where(this, where); } ``` -------------------------------- ### Using select for property filtering Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderListenableSelect/select.html Example of watching only a specific property to avoid rebuilds when other properties change. ```dart @override Widget build(BuildContext context, WidgetRef ref) { final age = ref.watch(personProvider.select((p) => p.age)); return Text('$age'); } ``` -------------------------------- ### run(MutationTarget target, Future cb(MutationTransaction tsx)) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/Mutation/run.html Starts a mutation and sets its state based on the result of the provided callback. The state transitions to MutationPending, then to MutationSuccess or MutationError depending on the callback outcome. ```APIDOC ## run ### Description Starts a mutation and sets its state based on the result of the callback. This sets the mutation state to MutationPending, calls the callback, then sets the mutation state to either MutationSuccess or MutationError depending on whether the callback completes successfully or throws an error. ### Signature `Future run(MutationTarget target, Future Function(MutationTransaction tsx) cb)` ### Parameters - **target** (MutationTarget) - The target of the mutation. - **cb** (Future Function(MutationTransaction tsx)) - The callback function to execute within the mutation transaction. ### Returns - **Future** - A future that completes with the result of the callback. ``` -------------------------------- ### bool get mounted Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Ref/mounted.html A getter that returns true if the Ref is active and false if the provider has been disposed. It is recommended to use this or onDispose to handle cleanup and prevent race conditions. ```APIDOC ## bool get mounted ### Description Returns a boolean indicating whether the current Ref is still active. If false, the provider has been disposed and further operations should be halted. ### Usage ```dart if (!ref.mounted) return; ``` ``` -------------------------------- ### listen(ProviderListenable provider, void listener(StateT? previous, StateT next), {void onError(Object error, StackTrace stackTrace)?, bool weak = false}) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/WidgetRef-class.html Listen to a provider and call a listener whenever its value changes. ```APIDOC ## listen(ProviderListenable provider, void listener(StateT? previous, StateT next), {void onError(Object error, StackTrace stackTrace)?, bool weak = false}) ### Description Registers a listener to a provider that is called whenever the provider's value changes. The listener is automatically removed when the widget is disposed. ### Parameters - **provider** (ProviderListenable) - Required - The provider to listen to. - **listener** (Function) - Required - The callback function triggered on state change. - **onError** (Function) - Optional - Error handler. - **weak** (bool) - Optional - Whether the listener is weak. ``` -------------------------------- ### ValueT build() Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Notifier/build.html Initializes the Notifier. This method is called to compute the initial state and is re-executed if any dependencies watched via Ref.watch change. ```APIDOC ## ValueT build() ### Description Initializes a Notifier. It is safe to use Ref.watch or Ref.listen inside this method. If a dependency of this Notifier (when using Ref.watch) changes, then build will be re-executed. The Notifier instance is preserved between executions of build. ### Signature `ValueT build()` ### Notes - If this method throws, reading the provider will rethrow the error. - This method is marked with @visibleForOverriding. ``` -------------------------------- ### Implementing StateProvider for Product Selection Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateProvider/StateProvider.html Demonstrates using StateProvider to track a selected product ID and updating it via a GestureDetector. ```dart final selectedProductIdProvider = StateProvider((ref) => null); final productsProvider = StateNotifierProvider>((ref) => ProductsNotifier()); Widget build(BuildContext context, WidgetRef ref) { final List products = ref.watch(productsProvider); final selectedProductId = ref.watch(selectedProductIdProvider); return ListView( children: [ for (final product in products) GestureDetector( onTap: () => ref.read(selectedProductIdProvider.notifier).state = product.id, child: ProductItem( product: product, isSelected: selectedProductId.state == product.id, ), ), ], ); } ``` -------------------------------- ### state Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateController-class.html Property to get or set the current state of the controller. ```APIDOC ## state ### Description The current state of the StateController. Can be read or updated directly. ### Type - **StateT** ``` -------------------------------- ### Implementation of listen Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Ref/listen.html The internal implementation of the listen method, showing how it interacts with the element to manage provider subscriptions. ```dart @override ProviderSubscription listen( ProviderListenable provider, void Function(StateT? previous, StateT next) listener, { void Function(Object error, StackTrace stackTrace)? onError, bool weak = false, bool fireImmediately = false, }) { _throwIfInvalidUsage(); final sub = _element.listen( provider, listener, weak: weak, onError: onError, fireImmediately: fireImmediately, ); return sub; } ``` -------------------------------- ### Non-refreshable provider expression Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/misc/Refreshable-class.html Example of a provider expression that is not compatible with ref.refresh. ```dart ref.watch(provider.select((value) => value)); ``` -------------------------------- ### Refreshable provider expressions Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/misc/Refreshable-class.html Examples of provider expressions that are compatible with ref.refresh. ```dart ref.watch(provider); ref.watch(provider.future); ``` -------------------------------- ### StackTrace get stackTrace Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncError/stackTrace.html Retrieves the stack trace associated with the error. ```APIDOC ## StackTrace get stackTrace ### Description Returns the stack trace of the error associated with the AsyncError instance. ### Signature `StackTrace get stackTrace` ### Returns - **StackTrace** - The stack trace object corresponding to the error. ``` -------------------------------- ### Initialize StorageOptions Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_persist/StorageOptions/StorageOptions.html Defines the configuration options for state persistence, including the optional destroy key and cache duration. ```dart const StorageOptions({ this.destroyKey, this.cacheTime = const StorageCacheTime(Duration(days: 2)), }); ``` -------------------------------- ### ProviderFamily constructor Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/misc/ProviderFamily/ProviderFamily.html Initializes a new ProviderFamily with a creation function and optional configuration parameters. ```APIDOC ## ProviderFamily constructor ### Description Creates a new instance of a ProviderFamily, which allows creating providers that accept an argument. ### Signature ProviderFamily( StateT _createFn(Ref ref, ArgT arg), {String? name, Iterable? dependencies, bool isAutoDispose = false, Retry? retry} ) ``` -------------------------------- ### bool get closed Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderSubscription/closed.html Returns true if the subscription is closed, false otherwise. ```APIDOC ## bool get closed ### Description Returns a boolean value indicating whether the current ProviderSubscription is closed. ### Signature `bool get closed` ### Returns - **bool** - True if the subscription is closed, false if it is still active. ``` -------------------------------- ### bool get isPending Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/MutationState/isPending.html A getter that returns true if the mutation is currently pending. ```APIDOC ## bool get isPending ### Description Returns a boolean value indicating whether the mutation is currently pending. This is equivalent to checking if the mutation state is `MutationPending`. ### Signature `bool get isPending` ### Returns - **bool** - True if the mutation is pending, false otherwise. ``` -------------------------------- ### Storage constructor Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_persist/Storage/Storage.html Initializes a new instance of the Storage interface to enable database interaction for Riverpod persistence. ```APIDOC ## Storage constructor ### Description Creates an instance of the Storage interface. This interface is used in conjunction with NotifierPersistX.persist to enable persistence for a notifier. ### Signature Storage() ``` -------------------------------- ### overrideWith(StateT create(Ref ref, ArgT arg)) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/misc/ProviderFamily-class.html Overrides the provider's initialization function with a new implementation. ```APIDOC ## overrideWith(StateT create(Ref ref, ArgT arg)) ### Description Allows overriding the provider's creation logic, typically used for testing or dependency injection. ### Parameters - **create** (Function) - Required - The new initialization function to use for the provider. ``` -------------------------------- ### Pull-to-refresh implementation Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/WidgetRef/refresh.html Example of using ref.refresh within a RefreshIndicator to trigger a data fetch. ```dart final productsProvider = FutureProvider((ref) async { final response = await httpClient.get('https://host.com/products'); return Products.fromJson(response.data); }); class Example extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final Products products = ref.watch(productsProvider); return RefreshIndicator( onRefresh: () => ref.refresh(productsProvider.future), child: ListView( children: [ for (final product in products.items) ProductItem(product: product), ], ), ); } } ``` -------------------------------- ### Consume FutureProvider in a Widget Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/FutureProvider/FutureProvider.html Example of using ref.watch to listen to a FutureProvider and handle its AsyncValue states. ```dart Widget build(BuildContext context, WidgetRef ref) { AsyncValue config = ref.watch(configProvider); return config.when( loading: () => const CircularProgressIndicator(), error: (err, stack) => Text('Error: $err'), data: (config) { return Text(config.host); }, ); } ``` -------------------------------- ### AsyncValue hashCode implementation Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValue/hashCode.html Example showing how to override hashCode to represent the internal state of an AsyncValue. ```dart @override int get hashCode => Object.hash(runtimeType, _loading, valueFilled, _errorFilled); ``` -------------------------------- ### Mutation.run Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/Mutation-class.html Executes the mutation logic with an optional key for unique state tracking. ```APIDOC ## Mutation.run ### Description Executes the mutation logic. When using keys to distinguish between different calls to the same mutation, the same key must be passed to the run method as was used when watching the mutation. ### Parameters - **ref** (Ref) - Required - The provider reference used to execute the mutation. - **callback** (Function) - Required - The asynchronous function containing the mutation logic. ``` -------------------------------- ### Resume Subscription Implementation Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderSubscription/resume.html The abstract definition of the resume method within the ProviderSubscription class. ```dart void resume(); ``` -------------------------------- ### Get state property Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/misc/ProviderTransformer/state.html Retrieves the current state of the transformer. SyncProviderTransformerMixin will rethrow errors if present. ```dart AsyncResult get state => _state; ``` -------------------------------- ### bool get isPaused Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderSubscription/isPaused.html Returns a boolean value indicating the current pause state of the subscription. ```APIDOC ## bool get isPaused ### Description Returns whether the subscription is currently paused. If the subscription is resumed, the listener will receive the last event that was emitted while the subscription was paused. ### Signature `bool get isPaused` ### Returns - **bool** - True if the subscription is paused, false otherwise. ``` -------------------------------- ### bool get isIdle Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/MutationState/isIdle.html Returns true if the mutation is currently idle, indicating it has not been triggered or has been reset. ```APIDOC ## isIdle ### Description Returns a boolean indicating whether the mutation is currently idle. This is equivalent to checking if the mutation state is `MutationIdle`. ### Signature `bool get isIdle` ### Returns - **bool**: True if the mutation is idle, false otherwise. ``` -------------------------------- ### StorageOptions(String? destroyKey, StorageCacheTime cacheTime) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_persist/StorageOptions-class.html Constructor for creating a new StorageOptions instance to configure state persistence. ```APIDOC ## StorageOptions(String? destroyKey, StorageCacheTime cacheTime) ### Description Creates a configuration object to enable a Storage to persist state. These options are passed to the NotifierPersistX.persist method. ### Parameters - **destroyKey** (String?) - Optional - A key used to forcibly destroy the associated state. - **cacheTime** (StorageCacheTime) - Optional - The duration before the persisted data expires. Defaults to 2 days. ``` -------------------------------- ### call(ArgT argument) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateProviderFamily-class.html Creates a StateProvider instance from an external argument. ```APIDOC ## call(ArgT argument) ### Description Creates a StateProvider from an external value provided as an argument. ### Signature `StateProvider call(ArgT argument)` ### Parameters - **argument** (ArgT) - The argument used to create the specific provider instance. ``` -------------------------------- ### Check mutation idle state Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/MutationState/isIdle.html Use this property to verify if a mutation has not yet started or has been reset. ```dart bool get isIdle => this is MutationIdle; ``` -------------------------------- ### Define a StreamProvider Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/StreamProvider/StreamProvider.html Example of using StreamProvider.autoDispose to manage a web socket connection that emits string messages. ```dart final messageProvider = StreamProvider.autoDispose((ref) async* { // Open the connection final channel = IOWebSocketChannel.connect('ws://echo.websocket.org'); // Close the connection when the stream is destroyed ref.onDispose(() => channel.sink.close()); // Parse the value received and emit a Message instance await for (final value in channel.stream) { yield value.toString(); } }); ``` -------------------------------- ### Default runBuild Implementation Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifier/runBuild.html The standard implementation of runBuild which handles the creation of the notifier element. ```dart @mustCallSuper @override WhenComplete runBuild() => requireElement().handleCreate(ref, build); ``` -------------------------------- ### Using Multiple Family Parameters Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifierProvider/family-constant.html Demonstrates reading multiple instances of the same family provider with different parameters simultaneously. ```dart @override Widget build(BuildContext context, WidgetRef ref) { final frenchTitle = ref.watch(titleFamily(const Locale('fr'))); final englishTitle = ref.watch(titleFamily(const Locale('en'))); return Text('fr: $frenchTitle en: $englishTitle'); } ``` -------------------------------- ### StateController(StateT _state) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateController-class.html Constructor to initialize the state of the StateController. ```APIDOC ## StateController(StateT _state) ### Description Initializes the state of the StateController instance. ### Parameters - **_state** (StateT) - Required - The initial state value. ``` -------------------------------- ### Override hashCode implementation Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifierProvider/hashCode.html Example implementation of hashCode for an AsyncNotifierProvider, ensuring consistency with the object's state. ```dart @override int get hashCode { if (from == null) return super.hashCode; return from.hashCode ^ argument.hashCode; } ``` -------------------------------- ### Implementing hashCode in Dart Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_persist/PersistedData/hashCode.html Example of overriding the hashCode property using Object.hash to incorporate object state. ```dart @override int get hashCode => Object.hash(data, destroyKey, expireAt); ``` -------------------------------- ### overrideWith(NotifierT create(Ref ref, ArgT arg)) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/ChangeNotifierProviderFamily-class.html Overrides the provider with a new initialization function. ```APIDOC ### overrideWith(NotifierT create(Ref ref, ArgT arg)) #### Description Override the provider with a new initialization function. #### Signature `Override overrideWith(NotifierT create(Ref ref, ArgT arg))` ``` -------------------------------- ### Using selectAsync with FutureProvider Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifierProvider/selectAsync.html Demonstrates how to use selectAsync to watch a specific property of an asynchronous configuration provider, ensuring the dependent provider only rebuilds when that property changes. ```dart // A provider which asynchronously loads configurations, // which may change over time. final configsProvider = StreamProvider((ref) async { // TO-DO fetch the configurations, such as by using Firebase }); // A provider which fetches a list of products based on the configurations final productsProvider = FutureProvider((ref) async { // We obtain the host from the configs, while ignoring changes to // other properties. As such, the productsProvider will rebuild only // if the host changes final host = await ref.watch(configsProvider.selectAsync((config) => config.host)); return http.get('$host/products'); }); ``` -------------------------------- ### bool get mounted Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateNotifier/mounted.html A getter that returns true if the StateNotifier is still active, or false if dispose() has been called. ```APIDOC ## bool get mounted ### Description Returns a boolean value indicating whether the StateNotifier instance has been disposed. This is useful for checking if it is safe to perform operations that rely on the notifier's lifecycle. ### Return Value - **bool** - Returns true if the notifier is mounted, false if dispose() has been called. ``` -------------------------------- ### get method Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/MutationTransaction/get.html Reads the current state of a listenable and keeps it alive until the enclosing mutation completes. ```APIDOC ## get method ### Description Reads the current state of a listenable and keeps it alive until the enclosing mutation completes. This method ensures that the provider remains active during the transaction lifecycle. ### Signature StateT get(ProviderListenable listenable) ### Parameters - **listenable** (ProviderListenable) - Required - The provider or listenable to read the state from. ### Returns - **StateT** - The current state of the provided listenable. ``` -------------------------------- ### listen method Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderContainer/listen.html Listen to a provider and call a listener whenever its value changes. Returns a ProviderSubscription object to manage the subscription. ```APIDOC ## listen ### Description Listen to a provider and call `listener` whenever its value changes. Listeners are automatically removed when the provider rebuilds. Returns a `ProviderSubscription` object that allows cancelling the subscription early. ### Signature `ProviderSubscription listen(ProviderListenable provider, void listener(StateT? previous, StateT next), {bool fireImmediately = false, bool weak = false, void onError(Object error, StackTrace stackTrace)?})` ### Parameters - **provider** (ProviderListenable) - Required - The provider to listen to. - **listener** (void Function(StateT? previous, StateT next)) - Required - The callback function triggered on state changes. - **fireImmediately** (bool) - Optional - If true, calls the listener immediately with the current value. Defaults to false. - **weak** (bool) - Optional - If true, the listener does not cause the provider to be initialized or kept alive. Defaults to false. - **onError** (void Function(Object error, StackTrace stackTrace)?) - Optional - Callback for uncaught errors in the provider. ### Returns - **ProviderSubscription** - An object that allows cancelling the subscription. ``` -------------------------------- ### ConsumerState() Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ConsumerState/ConsumerState.html Initializes a new instance of ConsumerState for the specified ConsumerStatefulWidget. ```APIDOC ## ConsumerState() ### Description Creates a new instance of a ConsumerState object associated with a ConsumerStatefulWidget. This allows the stateful widget to interact with Riverpod providers. ### Signature `ConsumerState()` ### Type Parameters - **WidgetT**: The type of the ConsumerStatefulWidget that this state object belongs to. ``` -------------------------------- ### Using select for computed values Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderListenableSelect/select.html Example of using select to watch a computed boolean value, further optimizing rebuilds. ```dart @override Widget build(BuildContext context, WidgetRef ref) { final isAdult = ref.watch(personProvider.select((p) => p.age >= 18)); return Text('$isAdult'); } ``` -------------------------------- ### build() Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Notifier-class.html The build method is used to initialize the state of the Notifier. It must be overridden to return the initial value of the state. ```APIDOC ## build() ### Description Initializes the Notifier state. This method is called when the provider is first accessed. ### Returns - **ValueT** - The initial state value. ``` -------------------------------- ### Incorrect Family Usage Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifierProvider/family-constant.html Example of an invalid attempt to watch a family provider without passing the required parameter. ```dart Widget build(BuildContext context, WidgetRef ref) { // Error – messagesFamily is not a provider final response = ref.watch(messagesFamily); } ``` -------------------------------- ### T get debugState Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateNotifier/debugState.html A development-only getter that allows access to the state of a StateNotifier. It is marked as deprecated and is not functional in release mode. ```APIDOC ## T get debugState ### Description A development-only way to access state outside of StateNotifier. This property is not protected, unlike the standard state property, and is intended for use in tests. It will not function in release mode. ### Signature `T get debugState` ### Notes - **Deprecated**: Use `state` instead. - **Availability**: Development mode only. ``` -------------------------------- ### resume() Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderSubscription-class.html Resumes the subscription. ```APIDOC ### resume() Resumes a previously paused subscription. ``` -------------------------------- ### Implementation of get Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/MutationTransaction/get.html This method asserts that the transaction is not closed, creates a subscription to the listenable, and returns the current state. ```dart StateT get(ProviderListenable listenable) { assert( !_closed, 'Cannot access MutationTransaction after the mutation has completed', ); final sub = _container.listen(listenable, (_, _) {}); _subscriptions.add(sub as ProviderSubscription); return sub.read(); } ``` -------------------------------- ### Implementation of create method Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateNotifierProvider/create.html The create method delegates to the internal _create function using the provided Ref. ```dart @override NotifierT create(Ref ref) => _create(ref); ``` -------------------------------- ### Incorrect usage of ref.listen Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/WidgetRef/listen.html Examples of invalid locations for ref.listen, including inside event handlers or outside the build method. ```dart class Example extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return ListView.builder( itemBuilder: (context) { // This is accepted, as we are at the root of a "builder" ref.listen(counterProvider, (prev, next) {}); }, ); } } ``` ```dart class Example extends ConsumerStatefulWidget { @override ExampleState createState() => ExampleState(); } class ExampleState extends ConsumerState { @override void initState() { super.initState(); // Incorrect, we are not inside the build method. ref.listen(counterProvider, (prev, next) {}); } } ``` ```dart class Example extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return ElevatedButton( onTap: () { // Incorrect, we are inside the build method, but neither at its // root, nor inside a "builder". ref.listen(counterProvider, (prev, next) {}); } ); } } ``` -------------------------------- ### Sorting a todo-list with watch Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Ref/watch.html Demonstrates using watch to combine multiple providers into a single derived state that updates automatically. ```dart final sortProvider = StateProvider((_) => Sort.byName); final unsortedTodosProvider = StateProvider((_) => []); final sortedTodosProvider = Provider((ref) { // listen to both the sort enum and the unfiltered list of todos final sort = ref.watch(sortProvider); final todos = ref.watch(unsortedTodosProvider); // Creates a new sorted list from the combination of the unfiltered // list and the filter type. return [...todos].sort((a, b) { ... }); }); ``` -------------------------------- ### bool get hasListeners Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateNotifier/hasListeners.html Returns true if at least one listener has been added to the StateNotifier using addListener and has not yet been removed. ```APIDOC ## bool get hasListeners ### Description Returns a boolean value indicating whether the StateNotifier currently has any active listeners attached. ### Returns - **bool** - True if listeners are present, false otherwise. ``` -------------------------------- ### overrideWith(ValueT create(Ref ref, ArgT arg)) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateProviderFamily-class.html Overrides the provider with a new initialization function. ```APIDOC ## overrideWith(ValueT create(Ref ref, ArgT arg)) ### Description Overrides the provider with a new initialization function, allowing for custom state creation logic. ### Signature `Override overrideWith(ValueT create(Ref ref, ArgT arg))` ### Parameters - **create** (Function) - A function that takes a Ref and an argument to initialize the state. ``` -------------------------------- ### num? get progress Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/progress.html Retrieves the current progress of an asynchronous operation. The value is null by default and should be between 0 and 1 when set. ```APIDOC ## num? get progress ### Description Returns the current progress of the asynchronous operation. This value is typically used to track the state of a loading process and must be a number between 0 and 1. ### Usage ```dart // Setting progress manually state = AsyncLoading(progress: 0); await something(); ref.state = AsyncLoading(progress: 1); // Accessing progress final currentProgress = asyncValue.progress; ``` ``` -------------------------------- ### bool get isReloading Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/isReloading.html A getter that returns true if the provider is recomputing due to a dependency change, distinguishing it from manual refreshes. ```APIDOC ## bool get isReloading ### Description Returns true if the associated provider was recomputed because of a dependency change (using Ref.watch), after at least one value or error has already been emitted. This property helps distinguish between automatic dependency-driven rebuilds and manual refreshes. ### Return Value - **bool** - True if the provider is reloading due to a dependency change, false otherwise. ``` -------------------------------- ### Implementation of the create method Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/StateProvider/create.html This method is an override that delegates the creation logic to the internal _createFn. ```dart @override ValueT create(Ref ref) => _createFn(ref); ``` -------------------------------- ### NotifierProvider Constructor Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/NotifierProvider-class.html Creates a new NotifierProvider instance that exposes a synchronous Notifier. ```APIDOC ## NotifierProvider(NotifierT _createNotifier(), {String? name, Iterable? dependencies, bool isAutoDispose = false, Retry? retry}) ### Description Initializes a new NotifierProvider that manages a synchronous Notifier. ### Parameters - **_createNotifier** (NotifierT) - Required - A function that creates the Notifier instance. - **name** (String?) - Optional - A custom label for the provider. - **dependencies** (Iterable?) - Optional - A list of providers this provider depends on. - **isAutoDispose** (bool) - Optional - Whether the state should be disposed when no longer listened to. - **retry** (Retry?) - Optional - The retry strategy for the provider. ``` -------------------------------- ### get(ProviderListenable listenable) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/MutationTransaction-class.html Reads the current state of a provider and keeps it alive until the enclosing mutation completes. ```APIDOC ### Method `get(ProviderListenable listenable) → StateT` ### Description Reads the current state of a listenable and keeps it alive until the enclosing mutation completes. ### Parameters - **listenable** (ProviderListenable) - Required - The provider to read and keep alive. ``` -------------------------------- ### String toString() Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderObserverContext/toString.html Returns a string representation of the ProviderObserverContext, including the provider, container, and optional mutation details. ```APIDOC ## String toString() ### Description Returns a string representation of the ProviderObserverContext object. This is primarily used for debugging and logging to inspect the state of the context. ### Signature `String toString()` ### Returns - **String** - A formatted string containing the provider, container, and mutation information. ``` -------------------------------- ### Override hashCode implementation Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_mutation/MutationIdle/hashCode.html Example of overriding the hashCode property to return a constant value, typically used when equality logic is customized. ```dart @override int get hashCode => 0; ``` -------------------------------- ### ConsumerWidget.build Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ConsumerWidget-class.html The build method is where the widget's UI is defined. It provides a WidgetRef instance which allows the widget to watch providers for state changes. ```APIDOC ## Widget build(BuildContext context, WidgetRef ref) ### Description Describes the part of the user interface represented by this widget. This method is called whenever the widget needs to be rebuilt, such as when a watched provider emits a new value. ### Parameters - **context** (BuildContext) - The location in the tree where this widget builds. - **ref** (WidgetRef) - An object used to interact with providers, specifically for watching state changes. ``` -------------------------------- ### bool get hasValue Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/hasValue.html Checks if the AsyncValue contains a value. Note that this can be true even if the state is currently loading or contains an error. ```APIDOC ## bool get hasValue ### Description Returns a boolean indicating whether a value is currently set in the AsyncValue. This property remains true even if the instance is in a loading state or contains an error. ### Signature `bool get hasValue` ### Returns - **bool** - True if a value is present, false otherwise. ``` -------------------------------- ### Implementation of allProviders Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderContainer/allProviders.html The internal implementation logic for retrieving providers, including recursive calls to parent containers. ```dart Iterable allProviders({Family? family}) { final providers = family != null ? _pointerManager.listFamilyProviders(family) : _pointerManager.listProviders(); if (container.parent case final parent?) { return providers.followedBy(parent.allProviders(family: family)); } return providers; } ``` -------------------------------- ### void debugReassemble() Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderContainer/debugReassemble.html Executes the debugReassemble method on all provider elements managed by the container. This method is only active when kDebugMode is true. ```APIDOC ## void debugReassemble() ### Description Triggers the `debugReassemble` method on all providers currently managed by the `ProviderContainer`. This is primarily intended for development environments to handle hot-reload scenarios. ### Signature `void debugReassemble()` ### Notes - This method only performs actions when `kDebugMode` is set to true. - It iterates through all provider elements returned by `getAllProviderElements()` and invokes their respective `debugReassemble` methods. ``` -------------------------------- ### bool get isLoading Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/isLoading.html Returns true if the AsyncValue is currently loading a new value. Note that this can be true simultaneously with hasValue or hasError. ```APIDOC ## bool get isLoading ### Description Returns a boolean indicating whether a new value is currently being asynchronously loaded. This property remains true even if the AsyncValue already holds a previous value or an error state. ### Signature `bool get isLoading` ``` -------------------------------- ### bool get hasError Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/hasError.html A getter that returns true if the AsyncValue instance contains an error. Note that this can be true simultaneously with hasValue or isLoading. ```APIDOC ## bool get hasError ### Description Returns a boolean indicating whether the current AsyncValue instance contains an error. This is determined by checking if the internal error state is non-null. ### Usage ```dart if (asyncValue.hasError) { // Handle the error state } ``` ### Returns - **bool** - True if an error is present, false otherwise. ``` -------------------------------- ### Implementing a LoggingMixin with runBuild Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AnyNotifier/runBuild.html Use this pattern to intercept the build process of any notifier for logging or side effects. ```dart mixin LoggingMixin on AnyNotifier { @override WhenComplete runBuild() { print('Will build $this'); final result = super.runBuild(); print('Did build $this'); return result; } } ``` -------------------------------- ### Implementation of the create method Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/ChangeNotifierProvider/create.html This method is marked as @nodoc and serves as an internal implementation detail for creating the notifier. ```dart @override NotifierT create(Ref ref) => _createFn(ref); ``` -------------------------------- ### int get hashCode Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValue/hashCode.html Returns the hash code for the AsyncValue instance, calculated based on its internal state (loading, value, and error). ```APIDOC ## int get hashCode ### Description The hash code for this object. A hash code is a single integer which represents the state of the object that affects operator == comparisons. ### Implementation ```dart @override int get hashCode => Object.hash(runtimeType, _loading, valueFilled, _errorFilled); ``` ``` -------------------------------- ### FutureOr build() Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifier/build.html Initializes the AsyncNotifier. This method is intended to be overridden by the user to define the initial state of the notifier. It is safe to use Ref.watch or Ref.listen within this method, and it will re-execute if dependencies change. ```APIDOC ## FutureOr build() ### Description Initializes an AsyncNotifier. It is safe to use Ref.watch or Ref.listen inside this method. If a dependency of this AsyncNotifier changes, build will be re-executed, but the AsyncNotifier instance will be preserved. ### Signature `@visibleForOverriding FutureOr build();` ### Behavior - If this method throws or returns a future that fails, the error will be caught and an AsyncError will be emitted. - The method is intended to be overridden by subclasses. ``` -------------------------------- ### bool get isRefresh Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Ref/isRefresh.html A boolean property that returns true if the provider was recomputed due to a refresh or invalidate call rather than a dependency change. ```APIDOC ## bool get isRefresh ### Description Returns a boolean value indicating whether the provider was recomputed without any dependency change. This is typically triggered when `refresh` or `invalidate` is called on the provider. ### Signature `bool get isRefresh` ### Returns - **bool** - True if the provider was recomputed due to a refresh or invalidate, false otherwise. ``` -------------------------------- ### Initialize ProviderScope at the root Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderScope/ProviderScope.html Wrap the root application widget with ProviderScope to enable Riverpod functionality. ```dart void main() { runApp( // Enabled Riverpod for the entire application ProviderScope( child: MyApp(), ), ); } ``` -------------------------------- ### bool get isRefreshing Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/isRefreshing.html A getter that returns true if the provider is currently refreshing, meaning it was manually triggered to recompute without dependency changes. ```APIDOC ## bool get isRefreshing ### Description Returns true if the associated provider was forced to recompute even though none of its dependencies have changed, after at least one value or error was emitted. This occurs when using `Ref.invalidate` or `Ref.refresh`. ### Usage If a provider rebuilds due to a dependency change (via `Ref.watch`), `isRefreshing` will be false and `isReloading` will be true instead. ``` -------------------------------- ### AsyncData? get asData Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/asData.html Upcasts an AsyncValue into an AsyncData. Returns the AsyncData instance if the value is available, or null if the state is AsyncLoading or AsyncError. ```APIDOC ## AsyncData? get asData ### Description Upcasts an AsyncValue into an AsyncData. Returns the AsyncData instance if the value is available, or null if the state is AsyncLoading or AsyncError. Note that an AsyncData may still be in a loading or error state, such as during a pull-to-refresh operation. ### Signature `AsyncData? get asData` ### Returns - **AsyncData?** - The AsyncData instance if the state is data, otherwise null. ``` -------------------------------- ### Implementation of $view method Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/legacy/ChangeNotifierProvider/%24view.html This method returns a _View instance configured with the provided create function and optional disposeNotifier flag. ```dart @override ChangeNotifierProvider $view({ required Create create, bool? disposeNotifier, }) { return _View(this, create, disposeNotifier: disposeNotifier); } ``` -------------------------------- ### bool get isPaused Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Ref/isPaused.html Returns a boolean indicating if the Ref is currently paused. A provider is paused when all of its listeners are removed or inactive, such as when a widget is not visible due to TickerMode. ```APIDOC ## bool get isPaused ### Description Returns whether this Ref is currently paused. A provider is considered paused when all of its listeners are removed or temporarily inactive. ### Return Value - **bool** - True if the provider is paused, false otherwise. ``` -------------------------------- ### Define a basic provider Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Provider/Provider.html Creates a simple provider that returns a static string value. ```dart final cityProvider = Provider((ref) => 'London'); ``` -------------------------------- ### runBuild Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AnyNotifier-class.html Executes the build method of the notifier. ```APIDOC ## runBuild() -> WhenComplete? ### Description Executes the Notifier.build method. This can be overridden to perform logic before or after the build process. ``` -------------------------------- ### Using Provider.family with Locale Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifierProvider/family-constant.html Demonstrates creating a provider that depends on a Locale parameter to return a localized string. ```dart final titleFamily = Provider.family((ref, locale) { if (locale == const Locale('en')) { return 'English title'; } else if (locale == const Locale('fr')) { return 'Titre Français'; } }); // ... @override Widget build(BuildContext context, WidgetRef ref) { final locale = Localizations.localeOf(context); // Obtains the title based on the current Locale. // Will automatically update the title when the Locale changes. final title = ref.watch(titleFamily(locale)); return Text(title); } ``` -------------------------------- ### bool get retrying Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/retrying.html Returns true if an error was emitted and is currently being retried. This can be true even if isLoading is false, indicating a retry is scheduled but the delay has not yet elapsed. ```APIDOC ## bool get retrying ### Description Returns a boolean indicating if an error emitted by the AsyncValue is currently being retried. This property can be true while isLoading is false, which occurs when a retry is scheduled but the delay period has not yet elapsed. ### Signature `bool get retrying` ### Returns - **bool**: True if the error is currently being retried, false otherwise. ``` -------------------------------- ### int get hashCode Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/StreamNotifierProvider/hashCode.html Returns the hash code for the StreamNotifierProvider instance. This value is calculated based on the provider's 'from' and 'argument' properties to ensure consistency with equality checks. ```APIDOC ## int get hashCode ### Description The hash code for this object. A hash code is a single integer which represents the state of the object that affects operator == comparisons. ### Implementation ```dart @override int get hashCode { if (from == null) return super.hashCode; return from.hashCode ^ argument.hashCode; } ``` ``` -------------------------------- ### read(KeyT key) Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/experimental_persist/Storage/read.html Reads the data associated with the provided key. If no data exists, it returns null. It is recommended to implement this synchronously if possible to improve UI responsiveness. ```APIDOC ## read(KeyT key) ### Description Reads the data associated with `key`. If no data is associated with `key`, this method returns `null`. ### Signature `FutureOr?> read(KeyT key)` ### Parameters - **key** (KeyT) - Required - The key associated with the data to be retrieved. ### Returns - **PersistedData?** - The data associated with the key, or null if not found. ``` -------------------------------- ### bool get weak Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderSubscription/weak.html Returns a boolean indicating if the subscription maintains the provider state. If false and the provider is set to auto-dispose, the provider may be disposed despite an active subscription. ```APIDOC ## bool get weak ### Description Returns whether the subscription maintains the provider state. If false and ProviderBase.isAutoDispose is true, the provider may still be disposed even if this subscription is active. ### Signature `bool get weak` ``` -------------------------------- ### select Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/ProviderListenableSelect.html The select method allows you to partially listen to a provider by providing a selector function that returns a specific property or value from the provider's state. ```APIDOC ## select ### Description Partially listen to a provider. This method allows you to subscribe to a specific part of the provider's state, ensuring that the listener only triggers when the selected value changes. ### Signature `ProviderListenable select(OutT selector(InT value))` ### Parameters - **selector** (Function) - Required - A function that takes the current provider value (InT) and returns a specific part of that value (OutT). ### Returns - **ProviderListenable** - A new provider listenable that emits only the selected values. ``` -------------------------------- ### NotifierProvider constructor Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/NotifierProvider/NotifierProvider.html Creates a new NotifierProvider instance to manage state via a Notifier. ```APIDOC ## NotifierProvider constructor ### Description Creates a provider that exposes a synchronous Notifier. This is used for managing state that can be mutated. ### Signature NotifierProvider, ValueT>( NotifierT _createNotifier(), { String? name, Iterable? dependencies, bool isAutoDispose = false, Retry? retry, }) ### Parameters - **_createNotifier** (Function) - Required - A function that returns the Notifier instance. - **name** (String) - Optional - A debug name for the provider. - **dependencies** (Iterable) - Optional - A list of providers that this provider depends on. - **isAutoDispose** (bool) - Optional - Whether the provider should be disposed when no longer in use. Defaults to false. - **retry** (Retry) - Optional - Configuration for retrying the provider initialization. ``` -------------------------------- ### bool get isFromCache Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncValueExtensions/isFromCache.html A getter that returns true if the value was obtained using Riverpod's offline-persistence feature. When this property is true, the isLoading property is also expected to be true. ```APIDOC ## bool get isFromCache ### Description Returns a boolean indicating whether the current AsyncValue was obtained using Riverpod's offline-persistence feature. ### Usage When `isFromCache` is true, `isLoading` will also be true, indicating that the value is a cached version while a network request is potentially pending. ``` -------------------------------- ### int get hashCode Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/AsyncNotifierProvider/hashCode.html Returns the hash code for the AsyncNotifierProvider instance. This value is calculated based on the provider's 'from' and 'argument' properties to ensure consistency with equality checks. ```APIDOC ### Property `int get hashCode` ### Description The hash code for this object. A hash code is a single integer which represents the state of the object that affects operator == comparisons. ### Implementation ```dart @override int get hashCode { if (from == null) return super.hashCode; return from.hashCode ^ argument.hashCode; } ``` ``` -------------------------------- ### Combine multiple providers in a class Source: https://pub.dev/documentation/flutter_riverpod/3.4.1/flutter_riverpod/Provider/Provider.html Demonstrates creating an object that depends on multiple providers by watching them within the provider definition. ```dart final cityProvider = Provider((ref) => 'London'); final countryProvider = Provider((ref) => 'England'); final weatherProvider = Provider((ref) { final city = ref.watch(cityProvider); final country = ref.watch(countryProvider); return Location(city: city, country: country); }); class Location { Location({required this.city, required this.country}); final String city; final String country; String get label => '$city ($country)'; } ```