Skip to content

CommandButton

A Button backed by an AppCommand in the active command registry.

Learn more: Commands & shortcuts

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

CommandScope(
commands: [
AppCommand(
id: const CommandId('project.runTests'),
title: 'Run tests',
run: (_) => runTests(),
),
],
child: const CommandButton(
command: CommandId('project.runTests'),
variant: ButtonVariant.primary,
),
)

The command supplies the default label, enabled state, and action. This keeps a dedicated button consistent with command palettes, shortcuts, semantics, and programmatic invocation without repeating command policy.

The button must be below the CommandScope or app that registers command. Missing commands throw a StateError during build. A registered command whose visibility predicate is false omits the button from the tree, just as it is omitted from shortcuts, semantics, and palettes.

ParameterTypeDefaultDescription
command:CommandIdrequiredID of the active command this button presents.
label:String?—Optional visual label. Defaults to the command’s title.
variant:ButtonVariantButtonVariant.normalAccent applied to the underlying button.
focusNode:FocusNode?—Focus node for the underlying button.
autofocus:boolfalseWhether the underlying button requests focus when mounted.
style:CellStyle?—Base styling for the underlying button.

CommandButton is defined in packages/fleury/lib/src/catalog/command_button.dart.

Category: Inputs & controls · All widgets