toWidget method
Returns a the result of one of three builders depending on the current state of the Command. This function won't trigger a rebuild if the command changes states so it should be used together with get_it_mixin, provider, flutter_hooks and the like.
Implementation
Widget toWidget({
required Widget Function(TResult lastResult, TParam? param) onResult,
Widget Function(TResult lastResult, TParam? param)? whileExecuting,
Widget Function(Object? error, TParam? param)? onError,
}) {
if (_commandResult.value.hasError) {
return onError?.call(
_commandResult.value.error,
_commandResult.value.paramData,
) ??
const SizedBox();
}
if (isExecuting.value) {
return whileExecuting?.call(value, _commandResult.value.paramData) ??
const SizedBox();
}
return onResult(value, _commandResult.value.paramData);
}