$asyncComputed<U> function

  1. @Deprecated('Use KaeruWidget instead. This will be removed in a future version.')
AsyncComputed<U> $asyncComputed<U>(
  1. Future<U> getValue(), {
  2. U? defaultValue,
  3. U? beforeUpdate()?,
  4. bool notifyBeforeUpdate = true,
  5. void onError(
    1. dynamic error
    )?,
  6. dynamic immediate = false,
})

Creates an instance of AsyncComputed with the given async function.

  • _getValue: The function that fetches the computed value asynchronously.
  • defaultValue: A default value before the async computation completes.
  • beforeUpdate: A function to set a temporary value before computation.
  • notifyBeforeUpdate: If true, notifies listeners when beforeUpdate sets a new value.
  • onError: Callback function for handling errors during async computation.
  • immediate: If true, starts the async computation immediately upon creation.

The AsyncComputed instance is automatically disposed when the widget is disposed.

Note: This is part of the deprecated defineWidget API.

Implementation

@Deprecated('Use KaeruWidget instead. This will be removed in a future version.')
AsyncComputed<U> $asyncComputed<U>(final Future<U> Function() getValue,
        {U? defaultValue,
        U? Function()? beforeUpdate,
        bool notifyBeforeUpdate = true,
        void Function(dynamic error)? onError,
        immediate = false}) =>
    autoContextDispose(AsyncComputed<U>(getValue,
        defaultValue: defaultValue,
        beforeUpdate: beforeUpdate,
        notifyBeforeUpdate: notifyBeforeUpdate,
        onError: onError,
        immediate: immediate));