toWidget method

Widget toWidget({
  1. required Widget onData(
    1. TResult result,
    2. TParam? param
    ),
  2. Widget onNullData(
    1. TParam? param
    )?,
  3. Widget whileExecuting(
    1. TResult? lastResult,
    2. TParam? param
    )?,
  4. Widget onError(
    1. Object? error,
    2. TResult? lastResult,
    3. 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();
  }
}