execute method
Can either be called directly or by calling the object itself because Commands are callable classes
Will increase executionCount and assign lastPassedValueToExecute the value of param
If you have queued a result with queueResultsForNextExecuteCall it will be copies tho the output stream.
isExecuting, canExecute and results will work as with a real command.
Implementation
@override
void execute([TParam? param]) {
if (_restriction?.value == true) {
_ifRestrictedExecuteInstead?.call(param);
return;
}
if (!_canExecute.value) {
return;
}
_isExecuting.value = true;
executionCount++;
lastPassedValueToExecute = param;
// ignore: avoid_print
print('Called Execute');
if (returnValuesForNextExecute != null) {
returnValuesForNextExecute!.map(
(entry) {
if ((entry.isExecuting || entry.hasError) &&
_includeLastResultInCommandResults) {
return CommandResult<TParam, TResult>(
param,
value,
entry.error,
entry.isExecuting,
);
}
return entry;
},
).forEach((x) => _commandResult.value = x);
} else if (_noReturnValue) {
notifyListeners();
} else {
// ignore: avoid_print
print('No values for execution queued');
}
_isExecuting.value = false;
}