build method
Builds the UI according to the state of the Stream.
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 when isProd is true.
- 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 StreamBuilder<T>(
stream: stream,
initialData: initialData,
builder: (BuildContext context, AsyncSnapshot<T> snapshot) {
return buildFromSnapshot(context, snapshot);
},
);
}