FutureWorker<T> constructor

const FutureWorker<T>({
  1. Key? key,
  2. required Future<T> future,
  3. required Widget builder(
    1. BuildContext context,
    2. T data
    ),
  4. bool isProd = false,
  5. T? initialData,
  6. Widget emptyBuilder(
    1. BuildContext context
    )?,
  7. Widget errorBuilder(
    1. BuildContext context,
    2. Object? error
    )?,
  8. Widget loadingBuilder(
    1. BuildContext context
    )?,
})

Creates a FutureWorker that listens to the provided future and builds the UI based on its state.

  • future: The future to wait for.
  • builder: Function called when data is available.
  • isProd: Production mode flag. When true, hides the default empty state widget (shows nothing instead of OptionEmpty) when data is null. Useful for production environments where empty states should be minimal. Default: false.
  • initialData: Initial data to use while waiting for the future.
  • emptyBuilder: Function called when the data is null or empty.
  • errorBuilder: Function called when an error occurs.
  • loadingBuilder: Function called while loading.

Implementation

const FutureWorker({
  super.key,
  required this.future,
  required this.builder,
  this.isProd = false,
  this.initialData,
  this.emptyBuilder,
  this.errorBuilder,
  this.loadingBuilder,
});