createOnceAsync<T> function

AsyncSnapshot<T> createOnceAsync<T>(
  1. Future<T> factoryFunc(), {
  2. required T initialValue,
  3. void dispose(
    1. T
    )?,
})

createOnceAsync creates an object with the async factory function factoryFunc at the time of the first build and disposes it when the widget is disposed if the object implements the Disposable interface. initialValue is the value that will be returned until the factory function completes. When the factoryFunc completes the value will be updated with the new value and the widget will be rebuilt. dispose allows you to pass a custom dispose function to dispose of the object. if provided it will override the default dispose behavior.

Implementation

AsyncSnapshot<T> createOnceAsync<T>(Future<T> Function() factoryFunc,
    {required T initialValue, void Function(T)? dispose}) {
  assert(
      _activeWatchItState != null,
      'createOnceAsync can only be called inside a build function within a'
      ' WatchingWidget or a widget using the WatchItMixin');
  return _activeWatchItState!.createOnceAsync(factoryFunc,
      initialValue: initialValue, dispose: dispose);
}