toWidget method
Widget
toWidget(
{ - required Widget onData(
- TResult result,
- TParam? param
),
- Widget onNullData(
- TParam? param
)?,
- Widget whileExecuting(
- TResult? lastResult,
- TParam? param
)?,
- Widget onError(
- Object? error,
- TResult? lastResult,
- TParam? param
)?,
})
Implementation
Widget toWidget({
required Widget Function(TResult result, TParam? param) onData,
Widget Function(TParam? param)? onNullData,
Widget Function(TResult? lastResult, TParam? param)? whileExecuting,
Widget Function(Object? error, TResult? lastResult, TParam? param)? onError,
}) {
if (error != null) {
return onError?.call(error, data, paramData) ?? const SizedBox();
}
if (isExecuting) {
return whileExecuting?.call(data, paramData) ?? const SizedBox();
}
if (data != null) {
return onData(data as TResult, paramData);
} else {
return onNullData?.call(paramData) ?? const SizedBox();
}
}