createSyncNoParam<TResult> static method
- TResult func(),
- TResult initialValue, {
- ValueListenable<
bool> ? restriction, - bool includeLastResultInCommandResults = false,
- bool? catchAlways,
- String? debugName,
Creates a Command for a synchronous handler function with no parameter that returns a value
func
: handler function
initialValue
sets the .value
of the Command.
restriction
: ValueListenable<bool>
that can be used to enable/disable the command based on
some other state change. If omitted the command can be executed always except it's already executing
includeLastResultInCommandResults
will include the value of the last successful execution in
all CommandResult
values unless there is no result. This can be handy if you always want to be able
to display something even when you got an error.
As synchronous function doesn't give any the UI any chance to react on on a change of
.isExecuting
,isExecuting isn't supported for synchronous commands and will throw an
assert if you try to use it.
catchAlways
: overrides the default set by catchAlwaysDefault.
If false
, Exceptions thrown by the wrapped function won't be caught but rethrown
unless there is a listener on thrownExceptions or results.
debugName
optional identifier that is included when you register a globalExceptionHandler
or a loggingHandler
Implementation
static Command<void, TResult> createSyncNoParam<TResult>(
TResult Function() func, TResult initialValue,
{ValueListenable<bool>? restriction,
bool includeLastResultInCommandResults = false,
bool? catchAlways,
String? debugName}) {
return CommandSync<void, TResult>(
null,
func,
initialValue,
restriction,
includeLastResultInCommandResults,
false,
catchAlways,
debugName,
true,
);
}