fl_nodes_v2 library
A reusable, pannable and zoomable node graph editor.
The package splits into three layers, and each can be used on its own:
- Model — NodeGraph, GraphNode, NodePort and NodeConnection are immutable value types with no Flutter dependency beyond geometry.
- Controller — NodeEditorController owns the current graph, and reaches the rest through subsystems: NodeEditorHistory, NodeEditorSelection, NodeEditorCamera, NodeEditorLayout, NodeEditorClipboard, NodeEditorProject and NodeEditorRunner.
- View — NodeEditor renders the canvas and handles interaction, and
delegates the look of each node to a
nodeBuilderyou supply.
Classes
- AbsentPayload
- The wire exists and nothing has been written on it yet — the producer has not run, or ran and did not emit on that port.
- ConnectionAppearance
- How one wire is drawn: its colour, its width and whether it is dashed.
- ConnectionCaption
- A connection's caption, as it is drawn.
- ConnectionCheck
- A wire somebody is about to draw, as a ConnectionValidator sees it.
- ConnectionDash
- A dash pattern: alternating lengths drawn and skipped, in scene units.
- ConnectionGeometry
- Cached geometry for one connection, in scene coordinates.
- ConnectionLabel
- Where a connection's caption sits on screen, and how big it is.
- ConnectionLayout
- Builds connection paths once and keeps them until the graph changes.
- ConnectionPath
- Builds and probes the paths used for connections.
- ConnectionRouter
- Turns connections into drawable paths.
- ConnectionsPainter
- Draws every connection curve beneath the node layer.
- ConnectionSpan
- One span of a wire's route — from a port or a waypoint to the next.
- CubicSegment
- One cubic of a curved route, as ConnectionPath.segments builds it.
- DefaultNodeEditorLocalizations
- The English every host shows until it says otherwise.
- DefinitionResolution
- What came of a resolution.
- DerivedLinkLabel
- A caption the definition computes, and the app user cannot change.
- DiagnosticRaised
- The run made a remark. The same one is never made twice about the same port, which is the rule GraphRun.diagnostics already follows.
- DynamicFieldFamily
- A family whose declared fields depend on the node's current values.
- DynamicPortFamily
- A family rebuilt from the node's fields and links on every pass.
- EdgeScrollConfig
- How the canvas scrolls itself when a drag reaches its edge.
- EditableLinkLabel
- A caption the app user owns, edited by tapping it on the canvas.
- EmphasisPainter
- The focus layer: the scrim, the halos behind lifted cards, and the lifted wires redrawn above it.
- FieldFamily
- A group of GraphNode.data keys a definition owns.
- GraphDocument
- A whole saved document: the graph, the camera it was saved under, and whatever the host keeps alongside them.
- GraphDocumentMigrations
- The chain that carries an old document up to the current version.
- GraphEdit
- One change to the graph: what kind, and what it touched.
- GraphEmphasis
- Which parts of the graph are being pointed at.
- GraphFragment
- A detached piece of a graph: nodes, the wires and frames between them, and where it was taken from.
- GraphLogEntry
- One thing an executor said through NodeExecutionContext.log.
- GraphNode
- A single box on the canvas.
- GraphPayload
- What a GraphTraceValue carries, and whether it carries it at all.
- GraphRun
- What one execution of the graph did.
- GraphRunDiagnostic
- One remark about a run.
- GraphRunEvent
- One thing the runner did.
- GraphRunRecorder
- Collects events into a list.
- GraphTraceValue
- A value on a wire, as the trace saw it.
- GridPainter
- Draws the infinite background grid in screen space.
- GridShader
- Loads and configures the background grid's fragment shader.
- GridSnap
- Rounding onto the grid the canvas draws.
- LinkDefinition
- The rule for one kind of connection, matched against NodeConnection.type.
- LinkLabel
- Who decides a link's caption.
- LinkResolutionContext
- What a LinkLabelBuilder may look at.
- LogEmitted
- An executor said something through NodeExecutionContext.log.
- MemoHit
- A pure data node was read and did not need to run, because nothing it reads has changed since it last did.
- MinimapConfig
- What the host decides about the minimap.
- MinimapController
- The minimap panel's own state: where it sits, how big it is, whether it is folded away, and what it draws.
- MinimapPainter
- Draws the whole document small: every node as a rect, and a wash over everything the canvas is not currently showing.
- MinimapProjection
- Scene coordinates to minimap-panel coordinates.
- MinimapScene
- The scene-space geometry the minimap draws, rebuilt only when the graph moves.
- NodeComment
- A free-standing note the app user writes on the canvas.
- NodeConnection
- A directed edge between an output port and an input port.
- NodeDefinition
- The rule that normalises one kind of node.
- NodeDefinitionRegistry
- The definitions a document is normalised against.
- NodeEditor
- An interactive, pannable and zoomable node graph canvas.
- NodeEditorCamera
- The view onto the scene: pan, zoom, framing.
- NodeEditorClipboard
- Copy, cut, paste and duplicate over the selection.
- NodeEditorController
- The single source of truth for a NodeEditor.
- NodeEditorEmphasis
- The current GraphEmphasis, and the bookkeeping around changing it.
- NodeEditorHistory
- The undo stack, and the transactions that collapse a drag into one step.
- NodeEditorLayout
- Where things are: node sizes, the spatial index built from them, and every query that answers "what is at this point".
- NodeEditorLocalizations
- The words the editor's own chrome says: its context menus, its dialogs, the minimap's bar and gear, the empty comment.
- NodeEditorMenuHost
- Renders NodeMenuEntry lists as a Material menu anchored to a point.
- NodeEditorMenus
- The editor's right-click menus.
- NodeEditorProject
- The document as a whole: what is open, whether it has been saved, and the conversions to and from JSON.
- NodeEditorRunner
- Runs the graph.
- NodeEditorScope
- Exposes the editor's controller and theme to node bodies built below it.
- NodeEditorSelection
- The selected nodes and connections.
- NodeEditorState
- NodeEditorTheme
- Visual configuration for the canvas chrome: grid, connections, ports, selection affordances and zoom limits.
- NodeExecutionContext
- Everything a NodeExecutor is given, and everything it can do.
- NodeField
- One entry in GraphNode.data, as the definition declares it.
- NodeFieldGroup
- One field family's declared keys, as a document records them.
- NodeFieldMergeContext
- What a NodeFieldMerge sees when carrying values across an iteration.
- NodeFields
- Ready-made inheritance policies.
- NodeFinished
- A node's turn is over, one way or another.
- NodeGeometry
- Pure functions turning the data model into canvas geometry.
- NodeGraph
- An immutable snapshot of the whole graph.
- NodeGraphCodec
- Converts a GraphDocument to and from JSON-shaped maps.
- NodeGroup
- A named frame drawn behind a set of nodes.
- NodeMenuCanvasTarget
- NodeMenuConnectionTarget
- NodeMenuEntry
- One row of a context menu.
- NodeMenuGroupTarget
- NodeMenuNodeTarget
- NodeMenuPortTarget
- NodeMenuRequest
- Everything a menu needs that the controller cannot supply on its own.
- NodeMenuTarget
- What the app user right-clicked.
- NodePort
- A connection endpoint attached to a GraphNode.
- NodePortRemoval
- Ready-made policies for connections left behind by a vanished port.
- NodeRenderState
- Interaction state handed to the host's node builder.
- NodeResolutionContext
- Everything a builder may look at while deciding a node's shape.
- NodeSketch
- One node, zoomed out: a filled box with an optional border and parts drawn over it, in the node's coordinates.
- NodeSketches
- Level of detail: zoomed out past below, nodes are drawn from the host's sketch by one painter instead of being built as widgets.
- NodeStarted
- A node is about to take a turn.
- OrthogonalRoute
- Where a wire runs when it is drawn in right angles: the corners of one span, from a port or a waypoint to the next.
- OverlayPainter
- Draws transient interaction feedback above the nodes: the in-flight connection curve and the marquee selection rectangle.
- PathArrow
- A direction marker sampled from a connection's curve.
-
PayloadCodec<
T extends Object> - Carries one host type across the document boundary.
- PayloadCodecs
- The host types a document may carry beyond plain JSON.
- PendingConnection
- The connection currently being dragged out of a port.
- PolylineSpan
- The legs of one span of an orthogonal route, as ConnectionPath.orthogonalSpans builds it: corners runs from the span's start to its end, every leg between two of them axis-aligned.
- PortFamilies
- Ready-made PortFamilyBuilders for the shapes that come up most.
- PortFamily
- A group of ports a definition owns.
- PortRef
- Identifies a single port on a single node.
- PortRemoval
- A node's ports changed and these connections referenced the ones that went.
- PortsPainter
- Draws every port handle on screen, in one pass.
- PresentPayload
- The value itself. Null is a value a node is entitled to emit, so a null here is a null on the wire and not an absence.
- RoutePoint
- The answer to ConnectionPath.nearestOnRoute.
- RunFinished
- The run is over, and this is what it did — the same object NodeEditorRunner.run returns.
- RunStarted
- The run has worked out where to start, and is about to.
- SketchBar
- A bar where something the host already measured would be, drawn as it is given. For text, SketchText does the measuring.
- SketchBox
- A filled box: a header band, a field, a swatch — with an optional border drawn inside it, which goes once it is too thin to see as the node's own border does.
- SketchPart
- Something drawn over a NodeSketch's fill.
- SketchText
- Text inside rect, drawn as one bar per line it lays out to.
- SpatialHashGrid
- A uniform spatial hash over axis-aligned rects.
- StaticFieldFamily
- A fixed set of declared fields.
- StaticPortFamily
- A family whose ports never change.
- ViewportTransform
- Maps scene (graph) coordinates to screen coordinates and back.
- WithheldPayload
- There is a value, and NodeEditorRunner.tracePayloads said not to carry it.
Enums
- CanvasDragBehavior
- What a primary-button drag on empty canvas does.
- CascadeSide
- A submenu entry whose panel slides to stay on screen rather than flipping above its button.
- ConnectionStyle
- How a wire is drawn between its two ports.
- GraphEditKind
- What an edit is doing to the graph.
- GraphLogLevel
- How loudly an executor said something. The host decides what each means.
- GraphRunIssue
- Something the runner noticed that is worth saying out loud but is not an error.
- NodeMenuEntryId
- Which built-in entry a NodeMenuEntry is.
- NodeRunState
- Where a node got to in the current or most recent run.
- PortDirection
- Whether a port accepts incoming connections or originates outgoing ones.
- PortKind
- What a port carries: a value, or the flow of execution itself.
- PortShape
- What a port's handle is drawn as.
- PortSide
- The edge of the node a port is anchored to.
- PortStorage
- Which of a node's ports a document carries.
Functions
-
payloadEquals(
Object? a, Object? b) → bool - Value equality for the open payloads the model carries.
-
payloadHash(
Object? value) → int - The hash that goes with payloadEquals, so equal payloads hash equal.
-
showConnectionLabelEditor(
BuildContext context, {required String? initialValue, String? title}) → Future< String?> - The default editor for a link caption: a small modal with a text field.
-
showGroupNameEditor(
BuildContext context, {required String initialValue, String? title}) → Future< String?> - The default editor for a group's name: a small modal with a text field.
-
showNodeDescription(
BuildContext context, {required String description, String? title, Widget builder(BuildContext context, String description)?}) → Future< void> - Shows a node's description, read-only.
Typedefs
- ConnectionAppearanceResolver = ConnectionAppearance? Function(NodeConnection connection, NodePort from, NodePort to)
- Asked how a wire should look, every time it is painted.
- ConnectionEndpoints = ({Offset from, PortSide fromSide, Offset to, PortSide toSide})
- Resolved endpoints of a connection.
- ConnectionValidator = bool Function(ConnectionCheck check)
- Decides whether an output port may be wired to an input port.
- DefinitionDivergenceHandler = void Function(GraphNode node, int passes)
- Reports a node whose definition never settled.
-
FieldFamilyBuilder
= List<
NodeField> Function(NodeResolutionContext context) - Builds one field family's declarations from the node's current state.
-
GraphDocumentMigration
= Map<
String, Object?> Function(Map<String, Object?> document) - Lifts a document map one format version forward.
-
GraphDocumentSink
= Future<
bool> Function(Map<String, Object?> json) - Writes an encoded document wherever the host keeps them.
-
GraphDocumentSource
= Future<
Map< Function()String, Object?> ?> - Produces an encoded document, or null when there is nothing to open — a file picker the user dismissed, say.
- GraphEditGuard = bool Function(GraphEdit edit)
- Asked before an edit lands. Returning false abandons it.
- GraphEditListener = void Function(GraphEdit edit)
- Told after an edit landed.
-
GraphLayout
= Map<
String, Offset> Function(NodeGraph graph, Size sizeOf(GraphNode node)) - Works out where every node should go.
- GraphRunListener = void Function(GraphRunEvent event)
- Told about a run as it happens. See NodeEditorRunner.onEvent.
- LinkLabelBuilder = String? Function(LinkResolutionContext context)
- Builds a link's caption from the connection and the graph around it.
- MinimapNodeColor = Color? Function(GraphNode node)
- The colour a node is drawn in on the map, or null to take the default.
-
NodeExecutor
= Future<
void> Function(NodeExecutionContext context) - What a node does when the flow reaches it.
-
NodeFieldMerge
= Map<
String, Object?> Function(NodeFieldMergeContext context) - Carries field values across an iteration of the definition.
- NodeHeightResolver = double? Function(NodeResolutionContext context)
- Returns the node's declared height, or null to size it to its content.
-
NodeMenuBuilder
= List<
NodeMenuEntry> Function(NodeMenuRequest request, List<NodeMenuEntry> defaults) - Decides the entries of a menu, given the ones the editor would have shown.
- NodeSketcher = NodeSketch Function(GraphNode node, Size size)
-
Describes
nodeas it should look zoomed out, laid out atsize. - NodeWidgetBuilder = Widget Function(BuildContext context, GraphNode node, NodeRenderState state)
- Builds the body of a node. The editor supplies the frame, ports, hit testing and dragging; this decides what the box looks like.
-
PayloadDecoder<
T extends Object> = T Function(Object? json) - Rebuilds a host value from the JSON PayloadEncoder produced.
-
PayloadEncoder<
T extends Object> = Object? Function(T value) - Turns a host value into a JSON value.
-
PortFamilyBuilder
= List<
NodePort> Function(NodeResolutionContext context) - Builds one port family's ports from the node's current state.
- PortRemovalHandler = NodeGraph Function(PortRemoval removal)
- Decides what happens to connections whose port has just disappeared.
- WaypointRef = ({String connectionId, int index})
- One waypoint of one connection: which wire, and which of its points.
Exceptions / Errors
- GraphDocumentException
- Something went wrong converting a document, and this says where.
- GraphDocumentFormatException
- The document is not shaped the way this version expects.
- GraphDocumentVersionException
- The document was written in a version this build cannot read.
- GraphRunException
- A run that could not continue.
- UnencodablePayloadException
- A value in the graph has no JSON representation and no registered codec.