build method

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

Builds the UI based on the state of the Future.

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 in production.
  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 FutureBuilder<T>(
    initialData: initialData,
    future: future,
    builder: (BuildContext context, AsyncSnapshot<T> snapshot) {
      return buildFromSnapshot(context, snapshot);
    },
  );
}