ExtendedFutureBuilder<T> constructor
ExtendedFutureBuilder<T> ({
- Key? key,
- dynamic initialData,
- Future? future,
- AsyncSnapshotBuilder<
T> ? onNone, - AsyncSnapshotBuilder<
T> ? onWaiting, - AsyncSnapshotBuilder<
T> ? onActive, - AsyncSnapshotBuilder<
T> ? onDone, - AsyncSnapshotBuilder<
Object?> ? onError,
Implementation
ExtendedFutureBuilder({
super.key,
super.initialData,
super.future,
/// [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();
}
});