DiagramVerb class final

A named, typed edit: the one way every surface changes a diagram.

The property panel, canvas overlays, toolbars, keyboard shortcuts, menus, agents and typed Dart extensions all call DiagramController.perform. A verb declares its parameters so it can be discovered, answers DiagramController.canPerform with a reason and performs one undoable edit through the controller.

Verbs are contributed by the definitions that own them: element verbs by extensions, a shape's own verbs by its ShapeDefinition, text verbs by the DiagramTextDefinition filling a slot and structured content verbs by the content layer. A shape binds its parts' verbs to its parts; callers never name slots.

final setCount = DiagramVerb.update<ShapeElement>(
  id: 'setCount',
  label: 'Set count',
  parameters: [DiagramVerbParameter.integer('count', minimum: 0)],
  update: (shape, call) => shape.copyWith(
    values: {...shape.values, 'count': call.arg<int>('count')},
  ),
);

Constructors

DiagramVerb({required String id, required String label, required DiagramVerbSymmetry symmetry, required EditResult perform(DiagramVerbCall call), String description = '', List<DiagramVerbParameter<Object?>> parameters = const [], DiagramVerbTarget target = DiagramVerbTarget.element, bool appliesTo(DiagramElement element, ShapeRegistry registry)?, bool admitsLockedTargets = false, EditResult? check(DiagramVerbCall call)?})

Properties

admitsLockedTargets → bool
Whether the verb may target locked elements, as unlocking does. Its edit is still admitted like any other.
final
description → String
final
hashCode → int
The hash code for this object.
no setterinherited
id → String
The name callers perform, unique within a target's verb set.
final
label → String
A short human-readable name, such as "Insert row".
final
parameters → List<DiagramVerbParameter<Object?>>
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
symmetry → DiagramVerbSymmetry
final
target → DiagramVerbTarget
final

Methods

appliesTo(DiagramElement element, ShapeRegistry registry) → bool
Whether this verb applies to element at all.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parameter(String name) → DiagramVerbParameter<Object?>?
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

update<E extends DiagramElement>({required String id, required String label, required E? update(E element, DiagramVerbCall call), String description = '', List<DiagramVerbParameter<Object?>> parameters = const [], DiagramVerbTarget target = DiagramVerbTarget.elements, bool appliesTo(DiagramElement element, ShapeRegistry registry)?, bool admitsLockedTargets = false, EditResult? check(DiagramVerbCall call)?, String editLabel(DiagramVerbCall call)?}) → DiagramVerb
A setter that replaces each target element of type E with update's result, as one edit labeled label. update returns the element unchanged, or null, when there is nothing to change.