ExtendedStreamBuilder<T> constructor
ExtendedStreamBuilder<T> ({
- Key? key,
- dynamic initialData,
- Stream? stream,
- AsyncSnapshotBuilder<
T> ? onNone, - AsyncSnapshotBuilder<
T> ? onWaiting, - AsyncSnapshotBuilder<
T> ? onActive, - AsyncSnapshotBuilder<
T> ? onDone, - 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();
}
});