build method
Builds the UI based on the state of the Future.
The build process follows this priority:
- If data is available and not empty (not null, not empty collections/strings), uses builder.
- If data is null or empty (empty List, Map, Set, Iterable, or String), uses emptyBuilder if provided, otherwise shows OptionEmpty or nothing in production.
- If an error occurs, uses errorBuilder if provided (receives the error object), otherwise shows OptionError.
- While loading, uses loadingBuilder if provided, otherwise shows OptionLoading.
Implementation
@override
Widget build(BuildContext context) {
return FutureBuilder<T>(
initialData: initialData,
future: future,
builder: (BuildContext context, AsyncSnapshot<T> snapshot) {
return buildFromSnapshot(context, snapshot);
},
);
}