build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds the UI according to the state of the Stream.

The build process follows this priority:

  1. If data is available and not empty (not null, not empty collections/strings), uses builder.
  2. 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.
  3. If an error occurs, uses errorBuilder if provided (receives the error object); otherwise shows OptionError.
  4. 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);
    },
  );
}