NodeFlowViewer<T> class

A simplified read-only viewer for node flow graphs.

This widget provides a read-only view of a node flow graph with pan and zoom capabilities but no editing functionality. It is a wrapper around NodeFlowEditor configured for display-only purposes.

Use this widget when you need to display a graph without allowing users to:

  • Drag or move nodes
  • Create or delete connections
  • Modify the graph structure

Users can still:

Example:

NodeFlowViewer<MyData>(
  controller: controller,
  theme: NodeFlowTheme.light,
  nodeBuilder: (context, node) {
    return Text(node.data.toString());
  },
  enablePanning: true,
  enableZooming: true,
  allowSelection: true,
  onNodeTap: (node) {
    print('Tapped: ${node?.id}');
  },
)

For convenience, you can also use NodeFlowViewer.withData to create a viewer with pre-loaded data:

NodeFlowViewer.withData<MyData>(
  theme: NodeFlowTheme.light,
  nodeBuilder: (context, node) => MyNodeWidget(node: node),
  nodes: myNodesMap,
  connections: myConnectionsList,
)
Inheritance
Available extensions

Constructors

NodeFlowViewer({Key? key, required NodeFlowController<T> controller, required Widget nodeBuilder(BuildContext context, Node<T> node), required NodeFlowTheme theme, Widget nodeContainerBuilder(BuildContext context, Node<T> node, Widget content)?, bool enablePanning = true, bool enableZooming = true, bool scrollToZoom = true, bool showAnnotations = false, bool allowSelection = false, ValueChanged<Node<T>?>? onNodeTap, ValueChanged<Node<T>?>? onNodeSelected, ValueChanged<Connection?>? onConnectionTap, ValueChanged<Connection?>? onConnectionSelected})
const

Properties

allowSelection bool
Whether to allow selection of nodes and connections.
final
controller NodeFlowController<T>
The controller managing the node flow state.
final
enablePanning bool
Whether to enable viewport panning with mouse/trackpad drag.
final
enableZooming bool
Whether to enable zoom controls (pinch-to-zoom, scroll wheel zoom).
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
nodeBuilder Widget Function(BuildContext context, Node<T> node)
Builder function for rendering node content.
final
nodeContainerBuilder Widget Function(BuildContext context, Node<T> node, Widget content)?
Optional builder for customizing the node container.
final
onConnectionSelected ValueChanged<Connection?>?
Called when a connection's selection state changes.
final
onConnectionTap ValueChanged<Connection?>?
Called when a connection is tapped.
final
onNodeSelected ValueChanged<Node<T>?>?
Called when a node's selection state changes.
final
onNodeTap ValueChanged<Node<T>?>?
Called when a node is tapped.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollToZoom bool
Whether trackpad scroll gestures should cause zooming.
final
showAnnotations bool
Whether to show annotation layers (sticky notes, markers, groups).
final
theme NodeFlowTheme
The theme configuration for visual styling.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited
withAnnotationLayer(NodeFlowController<T> controller) Widget

Available on Widget, provided by the AnnotationLayerSupport extension

Wraps this widget with an annotation layer.

Operators

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

Static Methods

withData<T>({Key? key, required NodeFlowTheme theme, required Widget nodeBuilder(BuildContext context, Node<T> node), required Map<String, Node<T>> nodes, required List<Connection> connections, NodeFlowConfig? config, Widget nodeContainerBuilder(BuildContext context, Node<T> node, Widget content)?, bool enablePanning = true, bool enableZooming = true, bool scrollToZoom = true, bool showAnnotations = false, bool allowSelection = false, ValueChanged<Node<T>?>? onNodeTap, ValueChanged<Node<T>?>? onNodeSelected, ValueChanged<Connection?>? onConnectionTap, ValueChanged<Connection?>? onConnectionSelected, GraphViewport? initialViewport}) NodeFlowViewer<T>
Convenience factory to create a viewer with data pre-loaded.