future property
latefinal
A provider that exposes the Future
created by a FutureProvider.
The instance of Future
obtained may change over time, if the provider
was recreated (such as when using Ref.watch).
This provider allows using async
/await
to easily combine
FutureProvider together:
final configsProvider = FutureProvider((ref) async => Configs());
final productsProvider = FutureProvider((ref) async {
// Wait for the configurations to resolve
final configs = await ref.watch(configsProvider.future);
// Do something with the result
return await http.get('${configs.host}/products');
});
Implementation
late final AlwaysAliveProviderBase<Future<State>> future =
AsyncValueAsFutureProvider(this, from: from, argument: argument);