ShapeDefinition class final
One production in the closed shape grammar: a shape's anatomy.
A shape is an outline — its surface, hit area and connection boundary — and a body of parts laid out inside or beside it, with typed instance values, optional container and collapse policies, and the behavior a person may exercise on the canvas. What an inspector edits follows from the anatomy: fill and stroke from the outline, corner radius from a rounded outline, text from the body's text parts, and a control per value.
New semantic shapes are composed from these declarations. They do not add painter, hit-test, handle, or editor code paths.
Constructors
-
ShapeDefinition({required String type, String? name, DiagramSize size = const DiagramSize(160, 100), DiagramSize minimumSize = const DiagramSize(24, 24), ShapeStyle style = const ShapeStyle(), ShapeShadowDefinition? shadow, ShapeOutline? outline = const ShapeOutline.rect(), ShapePart? body = ShapeParts.body, Map<
String, ValueField> values = const {}, Map<String, Object?> previewValues = const {}, Iterable<ShapeAdjustment> adjustments = const [], ShapeConnectionDefinition connection = const ShapeConnectionDefinition.outline(), ShapeContainer? container, ShapeCollapseDefinition? collapse, ShapeBehavior behavior = const ShapeBehavior(), DiagramTextFontSizeRange fontSizeRange = const DiagramTextFontSizeRange(), ShapeTextCreation textCreation = const ShapeTextCreation(), Iterable<DiagramVerb> verbs = const [], Iterable<ShapeAffordance> affordances = const [], Iterable<DiagramProperty< properties = const [], DiagramPropertyVisibility inspector = const DiagramPropertyVisibility.all()})ShapeElement, Object?> > -
ShapeDefinition.labeled(String type, {required String name, String? text, ShapeOutline outline = const ShapeOutline.rect(), ShapeConnectionDefinition connection = const ShapeConnectionDefinition.outline(), DiagramSize size = const DiagramSize(160, 100), ShapeStyle style = const ShapeStyle(), double padding = 16, ParagraphAlignment alignment = ParagraphAlignment.center, ShapeBehavior behavior = const ShapeBehavior(), Map<
String, ValueField> values = const {}}) -
A shape whose whole region is one padded, editable text slot
(
'label', initiallytextorname).factory - ShapeDefinition.symbol(String type, {required String name, ShapeOutline outline = const ShapeOutline.ellipse(), ShapePart? glyph, DiagramSize size = const DiagramSize(56, 56), DiagramSize minimumSize = const DiagramSize(24, 24), ShapeStyle style = const ShapeStyle(fill: DiagramColor(0xFFFFFFFF), strokeWidth: 2), ShapeConnectionDefinition connection = const ShapeConnectionDefinition.outline()})
-
A small, text-free symbol such as an event or state marker, with an
optional
glyphdrawn inside itsoutline.factory
Properties
-
adjustments
→ List<
ShapeAdjustment> -
On-canvas handles bound to numeric values, such as an arrow's head
length.
final
-
affordances
→ List<
ShapeAffordance> -
On-canvas controls beside the selected shape, such as a card's
optional tag, each performing one of the shape's verbs.
final
- alwaysPaintsBorder → bool
-
Whether the outline and its always-visible border paint in a separate
pass, as a clipping frame's do.
no setter
- behavior → ShapeBehavior
-
final
- body → ShapePart?
-
What the shape shows inside or beside its outline, compiled to
layers; null for none. The default is one editable
bodytext slot inset by 12.final - collapse → ShapeCollapseDefinition?
-
Present when a container can collapse to a compact presentation.
final
- connection → ShapeConnectionDefinition
-
final
- container → ShapeContainer?
-
Present when the shape owns child elements.
final
- cornerRadiusEditable → bool
-
Whether the style's corner radius rounds the outline, and so is
editable.
no setter
-
expandedLayers
→ Iterable<
ShapeLayerDefinition> -
layers including the portable fallbacks of widget slots, in order.
latefinal
- fontSizeRange → DiagramTextFontSizeRange
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hostsText → bool
-
Whether instances own a text story: the body has text or content.
latefinal
- imageValue → String?
-
The ImageValueField that choosing an image sets, if any.
latefinal
- inspector → DiagramPropertyVisibility
-
Which properties inspectors offer for shapes of this type: all by
default; a domain node may offer only its configuration.
final
-
layers
→ List<
ShapeLayerDefinition> -
The compiled body, in paint order: what renderers, picking and
editing read.
final
- minimumSize → DiagramSize
-
The smallest frame: the declared minimum, raised to fit a composed
body. A body that is a single text part scales with the shape.
final
- name → String?
-
Host-facing kind name used by palettes, inspectors and accessibility.
May be localized when building the registry; never replaces durable type.
final
-
optionalSlots
→ Map<
String, ShapeVisibility> -
Text slots that show only under a condition, such as a card's tag or an
entity's secondary section, keyed by slot.
latefinal
- outline → ShapeOutline?
-
The shape's own surface, or null for a shape that paints none, such as
a group, an image or a comment drawn by its body.
final
- paintsContent → bool
-
Whether the shape paints anything: a surface or a body.
no setter
- paintsSurface → bool
-
Whether the outline's fill and stroke are editable: the shape paints
its own surface.
no setter
- pathValue → String?
-
The PathValueField instances edit point by point, if the outline is
an editable path.
no setter
-
previewValues
→ Map<
String, Object?> -
Values a thumbnail or gallery shows instead of the defaults, such as
optional parts turned on so a preview reads as the full shape.
final
-
properties
→ List<
DiagramProperty< ShapeElement, Object?> > -
Custom inspector fields declared beside the shape's values and verbs.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadow → ShapeShadowDefinition?
-
final
- sidesValue → String?
-
The integer value a regular polygon outline takes its sides from.
no setter
- size → DiagramSize
-
Size of a newly created shape.
final
- style → ShapeStyle
-
Appearance of a newly created shape.
final
- textCreation → ShapeTextCreation
-
final
- textEditable → bool
-
Whether a person may edit this shape's text: its body has an editable
text slot or text content, and it is not collapsed.
latefinal
- type → String
-
final
-
values
→ Map<
String, ValueField> -
Declarations of each instance's durable values, keyed by name.
final
-
verbs
→ List<
DiagramVerb> -
This shape's own verbs, such as a card's
setTitle, beside the verbs every element has and those of its text and content parts.final
Methods
-
adjustmentField(
ShapeAdjustment adjustment) → NumberValueField -
The numeric field
adjustmentsets. -
createTextStory(
String elementId) → TextStory? - Materializes authored text using this definition's declared slots. Existing stories are never reset when definitions change.
-
createValues(
[Map< String, Object?> overrides = const {}]) → Map<String, Object?> - Supplies declared defaults once, then validates explicit overrides.
-
minimumSizeFor(
ShapeElement shape, Map< String, double> textHeights) → DiagramSize -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
presentationFor(
{required bool collapsed}) → ShapeDefinition - Cached presentation derived from this registration, sharing its content and connection grammar. No additional shape type or document is created.
-
textFor(
String slotId, [TextStory? story]) → DiagramTextDefinition -
The text filling
slotId: its text part, the cells of the content region instorythat owns it, or plain text. -
toString(
) → String -
A string representation of this object.
inherited
-
validateValues(
Map< String, Object?> values) → void - Requires exact declared keys; admission never silently supplies defaults. Invalid values throw an ArgumentError, which verbs and imports report as a denial.
-
withText(
DiagramTextDefinition text, {String? slot}) → ShapeDefinition -
A copy whose text parts hold
text, such as an extension's text in place of plain: every text part, or only the part fillingslot. The shape declares its parts; which text fills them is this explicit configuration, never a condition inside the shape.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited