ExtendedStreamBuilder<T> constructor

ExtendedStreamBuilder<T>({
  1. Key? key,
  2. dynamic initialData,
  3. Stream? stream,
  4. AsyncSnapshotBuilder<T>? onNone,
  5. AsyncSnapshotBuilder<T>? onWaiting,
  6. AsyncSnapshotBuilder<T>? onActive,
  7. AsyncSnapshotBuilder<T>? onDone,
  8. AsyncSnapshotBuilder<Object?>? onError,
})

Implementation

ExtendedStreamBuilder({
  super.key,
  super.initialData,
  super.stream,

  /// [ConnectionState.none] 显示的内容
  AsyncSnapshotBuilder<T>? onNone,

  /// [ConnectionState.waiting] 显示的内容
  AsyncSnapshotBuilder<T>? onWaiting,

  /// [ConnectionState.active] 显示的内容
  AsyncSnapshotBuilder<T>? onActive,

  /// [ConnectionState.done] 显示的内容
  AsyncSnapshotBuilder<T>? onDone,

  /// [error] 显示的内容
  AsyncSnapshotBuilder<Object?>? onError,
}) : super(builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
        if (snapshot.hasError) {
          return onError?.call(context, snapshot.error) ?? const SizedBox();
        }
        switch (snapshot.connectionState) {
          case ConnectionState.none:
            return onNone?.call(context, snapshot.data) ?? const SizedBox();
          case ConnectionState.waiting:
            return onWaiting?.call(context, snapshot.data) ??
                const SizedBox();
          case ConnectionState.active:
            return onActive?.call(context, snapshot.data) ?? const SizedBox();
          case ConnectionState.done:
            return onDone?.call(context, snapshot.data) ?? const SizedBox();
        }
      });