FutureWorker<T> constructor
const
FutureWorker<T> ({
- Key? key,
- required Future<
T> future, - required Widget builder(
- BuildContext context,
- T data
- bool isProd = false,
- T? initialData,
- Widget emptyBuilder(
- BuildContext context
- Widget errorBuilder(
- BuildContext context,
- Object? error
- Widget loadingBuilder(
- 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. Whentrue, 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,
});