future property

  1. @override
Refreshable<Future<T>> future
latefinal

Obtains the Future associated with 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

@override
late final Refreshable<Future<T>> future = _future(this);