CommandRegistry class
Scoped registry for active app commands.
Registries can form a parent chain. Local commands win over parent commands with the same ID, matching the app-kernel rule that nearer scopes have higher priority.
Constructors
-
CommandRegistry({CommandRegistry? parent, List<
AppCommand> commands = const <AppCommand>[]})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether at least one listener is registered.
no setterinherited
- lastResult → CommandInvocationResult?
-
no setter
-
localCommands
↔ List<
AppCommand> -
getter/setter pair
- parent ↔ CommandRegistry?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
activeCommands(
{BuildContext? buildContext}) → List< AppCommand> -
addListener(
VoidCallback listener) → void -
Registers
listenerto be called when this object changes.inherited -
command(
CommandId id, {BuildContext? buildContext}) → AppCommand? -
dispatch(
CommandId id, {BuildContext? buildContext}) → bool -
Starts
idfor a press — a shortcut, a button, a palette row, a semantic activation of one — without waiting on it, and returns whether it started. A command that is hidden, disabled or gone doesn't; a control reports that as a declined press by throwing SemanticActionDeclined. -
dispatchCommand(
AppCommand command, {BuildContext? buildContext}) → bool - invokeCommand for a press, as dispatch.
-
dispose(
) → void -
Marks this notifier as disposed and drops its listeners. Nulls the slots
in place (rather than replacing the backing list) so a dispose called
from within a listener leaves any in-progress notify walk
reading valid, now-empty slots. After disposal, addListener and
notify throw; removeListener remains safe for cleanup.
override
-
invoke(
CommandId id, {BuildContext? buildContext}) → Future< CommandInvocationResult> -
invokeCommand(
AppCommand command, {BuildContext? buildContext}) → Future< CommandInvocationResult> - Invokes a concrete command instance while still applying registry policy.
-
invokeCommandFromSemantics(
AppCommand command, {BuildContext? buildContext}) → Future< void> - invokeCommand for a semantic action, as invokeFromSemantics.
-
invokeFromSemantics(
CommandId id, {BuildContext? buildContext}) → Future< void> -
invoke for a semantic action — an agent's or assistive technology's
activation — whose result carries the outcome. Completes when the
command did; throws the command's error when it failed, so the action
reports
failed; and throws SemanticActionDeclined when the command is disabled or gone, so it reportsunsupportedrather thancompleted. -
isEnabled(
AppCommand command, {BuildContext? buildContext}) → bool -
isVisible(
AppCommand command, {BuildContext? buildContext}) → bool -
listen(
VoidCallback listener) → VoidCallback -
Registers
listenerand returns an idempotent cancellation function.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify(
) → void -
Publishes a change to every listener registered when the pass began.
inherited
-
removeListener(
VoidCallback listener) → void -
Removes a previously-registered listener.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited