FutureOrWidgetBuilder<T> typedef
FutureOrWidgetBuilder<T> =
Widget Function(BuildContext context, AsyncSnapshot<T> snapshot)
A builder function for widgets based on FutureOr async snapshots.
This function type is used by FutureOrBuilder to build widgets based on the state of a FutureOr value.
Type Parameters
T- The type of data expected from the async operation.
Parameters
context- The build context.snapshot- The current state of the async operation.
Returns
A widget built based on the snapshot state.
Example
FutureOrWidgetBuilder<String> builder = (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data!);
}
return CircularProgressIndicator();
};
Implementation
typedef FutureOrWidgetBuilder<T> = Widget Function(
BuildContext context, AsyncSnapshot<T> snapshot);