executeCommand method

bool executeCommand(
  1. String id,
  2. FluentDocument document, {
  3. BuildContext? buildContext,
})

Implementation

bool executeCommand(
  String id,
  FluentDocument document, {
  BuildContext? buildContext,
}) {
  final command = _commands[id];
  if (command == null) return false;
  final context = FluentCommandContext(document, buildContext: buildContext);
  if (command.canExecute?.call(context) == false) return false;
  if (command.undoDescription != null) {
    document.saveState(
      description: command.undoDescription!,
      forceNewAction: command.forceNewUndoAction,
    );
  }
  command.execute(context);
  return true;
}