getReactiveBuilder<T> function
AsyncWidgetBuilder<T>
getReactiveBuilder<T>({
- required DataWidgetBuilder<
T?> onData, - required Widget onFallback,
- required Widget? onWaiting,
Implementation
AsyncWidgetBuilder<T> getReactiveBuilder<T>({
required DataWidgetBuilder<T?> onData,
required Widget onFallback,
required Widget? onWaiting,
}) {
return (BuildContext context, AsyncSnapshot<T> snapshot) {
if (snapshot.hasData)
return onData(snapshot.data);
else
switch (snapshot.connectionState) {
case ConnectionState.active:
return onFallback;
default:
if (snapshot.hasError)
return onFallback;
else
return onWaiting ?? onFallback;
}
};
}