createSyncNoResult<TParam> static method

Command<TParam, void> createSyncNoResult<TParam>(
  1. void action(
    1. TParam x
    ), {
  2. ValueListenable<bool>? restriction,
  3. bool? catchAlways,
  4. String? debugName,
})

Creates a Command for a synchronous handler function with one parameter and no return type action: handler function 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 As synchronous function doesn't give 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. Can't be used with an ValueListenableBuilder because it doesn't have a value, but you can register a handler to wait for the completion of the wrapped function. 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<TParam, void> createSyncNoResult<TParam>(
  void Function(TParam x) action, {
  ValueListenable<bool>? restriction,
  bool? catchAlways,
  String? debugName,
}) {
  return CommandSync<TParam, void>(
    (x) => action(x),
    null,
    null,
    restriction,
    false,
    true,
    catchAlways,
    debugName,
    false,
  );
}