adapter library

Integration surface for diagram platform adapters, not the consumer API.

DiagramControllerAdapter.internals gives an adapter, such as the Flutter canvas, the engine access behind a controller's verbs: publications, gesture previews, grouped history, command groups and platform hooks.

It also carries the engine's transaction steps, publications, state and closure indexes. Application code should prefer the controller's verbs and batch; import this library to build verbs of your own on DiagramController.dispatch, for collaboration adapters and for low-level tests.

Classes

ConnectedElementCreation
One element creation request materialized with its incoming connector in a single canonical transaction.
ConnectedElementResult
The identities created by a connected creation: the new element and the connector that leads to it.
DiagramArrangementCommands
Headless arrangement commands over targets, by default the controller's selection, and its admitted scene.
DiagramCanvasInteractionWorld
The world in which the canvas has focus and no gesture or text edit is active.
DiagramClipboardCommands
Document clipboard operations, independent of platform clipboard storage.
DiagramConnectionCommands
Headless connector commands for one controller: creating connectors, previewing and committing connection gestures, and editing existing ones.
DiagramConnectorBendHandle
Dragging the bend handle of the connector elementId.
DiagramConnectorControlHandle
Dragging the control point at controlPointIndex of the connector elementId, from the connector's controlPoints at the start of the gesture.
DiagramConnectorEndHandle
Dragging the end endpoint of the connector elementId.
DiagramConnectorLabelClickHandle
A bound connector can accept a click without starting a document gesture.
DiagramConnectorLabelCommands
Canonical connector-label operations shared by future UI and host adapters.
DiagramConnectorStartHandle
Dragging the start endpoint of the connector elementId.
DiagramContentBand
A run of content operations that paint without a native widget between them.
DiagramContentOperation
One content paint step for an element: the whole element, or the phase of a shape that is split around mounted widgets.
DiagramContentSegment
Content-pass ordering used when native widgets interrupt canvas painting.
DiagramControlHandle
A draggable handle on a selected element, in world space.
DiagramControlHandleResolver
One geometry owner for both handle painting and pointer hit testing.
DiagramControllerInternals
What platform adapters, such as the Flutter canvas, need beyond the controller's verbs: publications, gesture previews, grouped history, the command groups behind the verbs and platform lifecycle hooks.
DiagramCreateFreehandHandle
Drawing a new freehand stroke with the id elementId, collecting its samples.
DiagramCreateLineHandle
Drawing a new connector of connectorType with the id elementId, from source.
DiagramCreateShapeHandle
Drawing a new shape of shapeType with the id elementId.
DiagramCreationCommands
Headless element creation commands for one controller.
DiagramCreationDefaults
Styles a host (such as a themed canvas) gives new content. Explicit participant choices in DiagramCreationStyles take precedence.
DiagramCreationHandle
Transient creation baseline and preview status live only for this gesture.
DiagramCreationStyles
Participant-local appearance choices for subsequent creations, not document edits.
DiagramCustomRegionHandle
A gesture on the interactive region regionId of the element elementId, reported to handler as ShapeRegionInteractions for interactionId.
DiagramCustomToolHandle
A gesture owned by a custom tool, which runs gesture from the editor state at gestureStart.
DiagramDragHandle
Closed gesture payloads: inactive operation fields are never stored.
DiagramEditConnectorLabelOnClick
A click on the connector connectorId that edits its label if the pointer stays near screenOrigin, in screen coordinates.
DiagramEditorInteractionWorld
The complete, closed set of editor focus worlds. Keeping this separate from Flutter focus nodes prevents a mounted editor from becoming a dead, non-interactive surface when focus changes.
DiagramEditorState
An immutable editor snapshot: the document, the installed extensions' options and the participant's local state.
DiagramEditTextOnClick
Starts editing the text of the element elementId at world, where doubleTap records whether the click was a double tap.
DiagramElementTransform
Pure geometry operations shared by headless commands and gesture previews.
DiagramEraserHandle
Erasing elements the pointer passes over.
DiagramFreehandGeometry
One contour for live ink, canonical materialization, painting and hit tests. Tolerances are measured at capture zoom, never re-applied to saved geometry.
DiagramFreehandSamples
Append-only live ink belongs to one gesture, never the canonical document. Point and pressure writes share one entry point; painters receive read-only views without copying the accumulated stroke on each pointer sample.
DiagramGestureInteractionWorld
A pointer sequence has one immutable owner until pointer-up or cancel. Gesture-specific payload is present only in this world, so canvas and text modes cannot accidentally retain an active transform or creation handle.
DiagramGridSnapping
Grid snapping as the canvas shows it, for gestures and headless controllers.
DiagramGrouping
Canonical structural grouping commands.
DiagramGroupingCommands
Structural selection operations over the admitted document and geometry.
DiagramHandleHitTest
Screen-space hit regions and priority for selection handles.
DiagramImageOutput
Optional image resources supplied by a platform output adapter.
DiagramInkOutline
Rebuildable, target-independent pressure stroke envelope.
DiagramInkStroke
A freehand stroke resolved to a smoothed contour, with a width multiplier for each point.
DiagramInteractionController
Semantic interaction ownership shared by every surface of a controller. Notifies when the canvas world changes, such as entering text editing.
DiagramMarqueeHandle
A marquee selection started at origin.
DiagramMoveClickIntent
A stationary pointer may select an object or activate its text, never both.
DiagramMoveHandle
Moving the selection.
DiagramMovePreview
A paint-only translation used while a large, closed frame subtree moves.
DiagramObjectCommands
Object commands use the same admitted scene and transaction path as input.
DiagramOptions
The diagram-wide state that is neither document content nor history: the options of every installed extension, keyed by each options value's Dart type, and the live parts of the diagram's configuration (its bounds, fonts and default font family).
DiagramOwnershipIndex
Rebuildable ownership and lock projection keyed by immutable document identity.
DiagramPanHandle
Panning the viewport.
DiagramParagraphCache
LRU retention is bounded by both paragraph count and source text size. Eviction releases cache references; it must not dispose resources still referenced by an immutable published scene.
DiagramParagraphCacheKey
Only paragraph-local shaping inputs belong in this key. Shape identity, paragraph identity, position, clipping height and vertical alignment affect placement afterward, so equal paragraphs in different shapes share an entry. Every shaper keys on the same inputs; foreground matters only to shapers whose retained paragraphs also paint, and is kept for all of them.
DiagramParticipantState
Immutable local interaction choices, independent of committed content. Each controller owns one such value. This value alone does not establish independent participant ownership.
DiagramPasteResult
The elements a paste adds, with fresh identities, and the ids of those to select afterwards.
DiagramPathCommands
Canonical path edits shared by hosts and direct manipulation.
DiagramPersistentList<T>
Immutable chunk sharing without retaining predecessor snapshots. Replacement copies one small chunk and its page table, never the complete element vector.
DiagramPointerGestureInteractionWorld
A pointer gesture whose drag handle needs no transform baseline.
DiagramPublication
One admitted state and geometry snapshot observed by every adapter.
DiagramRenderPlan
One render plan for an ordered element list: which elements each DiagramRenderPass paints. Pass membership is computed on first use.
DiagramResizeGeometry
Shared anchored box resize in the target's unrotated coordinate frame. The caller owns inverse transforms, snapping and pointer grab offset.
DiagramResizeHandle
Resizing from a handle of the element elementId, or of a multi-element selection when null.
DiagramResizeTransform
One immutable resize mapping for every element in a transform selection.
DiagramResolver
Turns a DiagramDocument into a ResolvedScene using a shape registry and a text layout engine.
DiagramRotateHandle
Rotating the element elementId from a handle.
DiagramSelectContentOnClick
A stationary object-level click enters an extension's canonical selection.
DiagramSelectionChromeProjection
Screen-space dimensions shared by selection-handle paint and hit testing.
DiagramSelectionIndex
Rebuildable ownership and internal-connection index for immutable documents.
DiagramSelectOnClick
Selects the element elementId, or toggles it in the selection when toggle is set.
DiagramSnapPolicy
Pure snapping rules shared by every direct-manipulation gesture.
DiagramSpatialIndex
A grid index of resolved elements by their bounds.
DiagramStep
One change a DiagramTransaction makes. There are four: insert elements, remove elements, replace one element and replace the whole document. Moves, resizes, rotations and text edits are replacements.
DiagramStoryCommands
Canonical text mutations for shapes, standalone text and connector labels. No mounted editor or platform text input is required. Text extensions add their commands through update. They change any text, including parts a person cannot edit on the canvas (ShapeText(editable: false)); locks and host policies still apply.
DiagramTextBoundaryMap
UTF-16 positions at extended grapheme boundaries in canonical story text. Boundaries span inline runs and are independent of visual line wrapping.
DiagramTextCommands
Pure canonical text operations shared by every shape editor adapter.
DiagramTextEditingInteractionWorld
The world in which the story storyId of the element elementId is being edited.
DiagramTouchNavigationHandle
Two-finger touch navigation of the viewport.
DiagramTransaction
An ordered set of steps applied together as one edit, with the label it carries in history and an optional selectionAfter.
DiagramTransformBaseline
Immutable input to every preview in one admitted transform sequence.
DiagramTransformCursorProjection
Canonical screen projection for resize and rotation cursor silhouettes.
DiagramTransformGestureInteractionWorld
A move, resize or rotate gesture, carrying the baseline every preview is computed from.
DiagramTransformPlan
Move, rotate and resize steps for one captured element set.
DiagramWidgetPlacement
The point in the content stream where owner's widget slot is mounted.
ElementCreation
One host-authored shape or standalone-text materialization request.
InsertElementsStep
Inserts new elements, in order.
RemoveElementsStep
Removes the requested elements with what depends on them: owned contents and connectors that would keep a binding to a removed element.
ReplaceDocumentStep
Replaces the whole expected document with replacement.
ReplaceElementStep
Replaces element before with after, which keeps its identity.
ShapeRegionInteraction
One step of a pointer gesture on an interactive region of a shape.
TextElementDefinition
Standalone text: a frame filled by one body text slot of textType, with no shape surface.

Enums

DiagramContentPhase
The part of an element a DiagramContentOperation paints.
DiagramControlHandleKind
The kind of edit a DiagramControlHandle performs when dragged.
DiagramDragKind
The kind of gesture a DiagramDragHandle represents.
DiagramRenderPass
Document paint passes, in order. Every renderer (canvas, PNG, SVG and minimap) paints a scene as these passes so output formats cannot drift.
DiagramStateAspect
Independent publication domains of a controller's state. Committed content excludes gesture previews; the live domains include this controller's own preview and its resolved geometry.
DiagramTransformOperation
Shared capability admission for explicit geometry operations.
ShapeRegionInteractionPhase
The stage of a pointer gesture on a shape region, as reported in ShapeRegionInteraction.phase.

Extensions

DiagramArrangementOrder on DiagramArrangementCommands
Paint-order commands for DiagramArrangementCommands.
DiagramArrangementResize on DiagramArrangementCommands
Size-based edits over the same resolved frames used by canvas handles.
DiagramArrangementTransforms on DiagramArrangementCommands
Explicit geometric edits share ownership expansion and canonical transforms.
DiagramConnectedCreationCommands on DiagramCreationCommands
Creation of an element together with the connector that leads to it, for DiagramCreationCommands.
DiagramConnectionEditingCommands on DiagramConnectionCommands
Routing and endpoint editing of existing connectors, for DiagramConnectionCommands.
DiagramConnectorLabelResizeCommands on DiagramConnectorLabelCommands
Resizing of connector labels, for DiagramConnectorLabelCommands.
DiagramControllerAdapter on DiagramController
Platform adapter access to a controller's engine. Exported only by package:vyuh_diagram_core/adapter.dart, never by the consumer library.
DiagramInteractionMove on DiagramInteractionController
Preview of a move gesture for DiagramInteractionController.
DiagramInteractionResize on DiagramInteractionController
Preview of a resize gesture for DiagramInteractionController.
DiagramInteractionRotate on DiagramInteractionController
Preview of a rotate gesture for DiagramInteractionController.
DiagramLaneArrangement on DiagramArrangementCommands
Lane arrangement for DiagramArrangementCommands.
DiagramResizeResolution on DiagramResolver
Uses the normal text/table layout to clamp a resize before anchoring it. No candidate scene or cache is published while measuring the constraint.

Properties

coreDiagramArrowheads → List<DiagramArrowheadDefinition>
final
coreDiagramPortShapes → List<DiagramPortShapeDefinition>
Built-in port markers. Extensions contribute more through DiagramExtension.portShapes.
final
diagramCoreExtensions → List<DiagramExtension>
The basic shapes and port markers, plain text, the grid, the default connector with straight routes, base arrowheads, interaction tools and the core verbs. Every diagram installs them first; an installed extension with the same id replaces one, and another extension's contribution with the same key replaces the core one.
final
diagramCoreVerbs → List<DiagramVerb>
The element and diagram verbs core installs: element state, geometry, structure, creation, connectors, text stories and paths.
final

Functions

arrangeConnectorLabels(ResolvedScene scene, Set<String> connectorIds, {required double spacing}) → Map<String, List<ConnectorLabel>>?
Plans label positions from measured geometry without changing the scene. Returns null if the bounded candidate set cannot place every requested label. Container interiors are available; leaf shapes and other labels are obstacles.
composeDiagramContent(Iterable<ResolvedElement> visible, {required bool hasBuilder(String widgetKey), bool isDynamic(ResolvedElement element)?}) → List<DiagramContentSegment>
Consumes already ordered visible elements, without a second spatial query. Text retains its existing final local pass; global ports/markers/chrome are deliberately outside this content stream.
cubicAt(DiagramPoint start, DiagramPoint firstControl, DiagramPoint secondControl, DiagramPoint end, double t) → DiagramPoint
The point at parameter t on a cubic Bézier curve.
defaultDiagramTools() → List<DiagramToolDefinition>
Optional defaults. Applications may omit, replace, or add registrations.
diagramAllowsTransform(ResolvedElement element, DiagramTransformOperation operation) → bool
diagramBatchRemovalClosure(DiagramDocumentBatch batch, Iterable<String> elementIds) → Set<String>
Existing elements removed with elementIds from the batch's current view, including dependencies introduced or released by its pending edits.
diagramBindingGeometryChanged(ResolvedFramedElement? before, ResolvedFramedElement after) → bool
Appearance does not participate in boundary attachment. Provider-controlled values and text stay conservative because they can move layers and ports.
diagramContainingOwner(ResolvedScene scene, DiagramPoint world, {Set<String> excluding = const {}}) → ResolvedShape?
Topmost child-owning clipped shape containing the point, using scene order.
diagramContrastingTextColor(DiagramFill background) → DiagramColor
Chooses the higher-contrast default ink against a fill composited on white.
diagramListEquals<T>(List<T> a, List<T> b) → bool
Whether a and b hold equal elements in the same order.
diagramRemovalClosure(DiagramDocument document, Iterable<String> elementIds) → Set<String>
Elements removed with their owner or a bound endpoint target.
diagramResizeSelectionClosure(DiagramDocument document, Set<String> ids, ShapeRegistry registry) → Map<String, DiagramElement>
A frame boundary can resize independently; logical groups scale their subtree.
diagramSelectionBounds(ResolvedElement element) → DiagramRect
Selection frame geometry shared by handles and headless arrangement.
diagramSelectionClosure(DiagramDocument document, Iterable<String> ids) → Map<String, DiagramElement>
Shared by manipulation, arrangement, and host commands.
diagramSelectionRoots(DiagramDocument document, Set<String> ids) → Set<String>
diagramVisibleGridSpacing({required DiagramGridPattern pattern, required DiagramRect bounds, required double gridSize, required double zoom}) → double
Shared density resolution for grid painting and direct manipulation.
flattenCubic(DiagramPoint start, DiagramPoint firstControl, DiagramPoint secondControl, DiagramPoint end, {required double tolerance, List<DiagramPoint>? output}) → List<DiagramPoint>
Appends an adaptive polyline for a cubic Bézier to output, excluding start, and returns output. Subdivision stops once both control points are within tolerance of the chord, or at a depth of 16.
immutableDiagramValues(Map<String, Object?> values) → Map<String, Object?>
Snapshots JSON-safe values recursively, rejecting cycles, non-finite numbers, non-string map keys and arbitrary objects. Shared by documents and intents. A snapshot previously returned by this function is returned unchanged.
layoutLaneFrames(Map<String, DiagramRect> lanes, {DiagramLaneDirection direction = DiagramLaneDirection.rows, DiagramSize? laneSize, double gap = 0}) → Map<String, DiagramRect>
Places lane boundaries in the supplied order. Contents are handled by the engine's ordinary ownership translation, never scaled by this planner.
pointInPolygon(DiagramPoint point, List<DiagramPoint> polygon) → bool
Even-odd containment of point in the closed polygon.
quadraticAt(DiagramPoint start, DiagramPoint control, DiagramPoint end, double t) → DiagramPoint
The point at parameter t on a quadratic Bézier curve.
sampleCubic(DiagramPoint start, DiagramPoint firstControl, DiagramPoint secondControl, DiagramPoint end, {required int steps}) → List<DiagramPoint>
steps + 1 uniformly parameterized points, including both ends.
sampleQuadratic(DiagramPoint start, DiagramPoint control, DiagramPoint end, {required int steps}) → List<DiagramPoint>
steps + 1 uniformly parameterized points, including both ends.
segmentDistance(DiagramPoint point, DiagramPoint start, DiagramPoint end) → double
Distance from point to the closed segment start–end.
segmentDistanceSquared(DiagramPoint point, DiagramPoint start, DiagramPoint end) → double
Squared distance from point to the closed segment start–end.
validateDiagramVerbSymmetry(Iterable<DiagramVerb> verbs, Map<String, DiagramVerb> scope) → void
Fails unless every verb in verbs is two-way: a setter, half of a pair whose counterpart in scope is itself a pair, or derived from a setter in scope. Every installed verb passes it when a diagram is built.
validatePngContainer(List<int> bytes) → (int, int)

Typedefs

ShapeRegionInteractionHandler = bool Function(ShapeRegionInteraction interaction)
A handled gesture retains its initiating callback for subsequent phases. Replacing the widget hook applies to future gestures.
TextStoryReplacement = ({TextStory after, TextStory before, String elementId})
One immutable expected/replacement pair for an atomic text edit.