KaeruFutureBuilder<T> extension
Extension for concise FutureBuilder usage with customizable states.
This extension simplifies handling different states of a Future<T>:
- success: when the future completes with data
- error: when the future completes with an error
- loading: while waiting for the future to complete
- noData: when the future completes with no data
Example:
myFuture.futureBuilder(
success: (ctx, data) => Text('Result: $data'),
error: (ctx, err) => Text('Error: $err'),
loading: (ctx) => const CircularProgressIndicator(),
noData: (ctx) => const Text('No result'),
);
- on
-
- Future<
T>
- Future<
Methods
-
futureBuilder(
{required Widget success(BuildContext, T data), Widget error(BuildContext, Object? error)?, Widget loading(BuildContext)?, Widget noData(BuildContext)?}) → Widget -
Available on Future<
Builds aT> , provided by the KaeruFutureBuilder extensionFutureBuilderwith shorthand callbacks for common states.