NodeWidget<T> class
A unified node widget that handles positioning, rendering, and interactions.
This widget is the primary UI component for rendering nodes in the flow graph. It handles:
- Positioning and sizing based on Node state
- Rendering ports at appropriate positions
- Applying theme-based or custom styling
- Managing user interactions (taps, hovers)
- Reactive updates via MobX observables
The widget supports two usage patterns:
- Custom content: Provide a child widget for complete control over node appearance
- Default style: Use NodeWidget.defaultStyle for standard node rendering
Appearance can be customized per-node by providing optional appearance parameters which will override values from the theme.
Example with custom content:
NodeWidget<MyData>(
node: myNode,
child: MyCustomNodeContent(data: myNode.data),
onNodeTap: (nodeId) => print('Tapped: $nodeId'),
backgroundColor: Colors.blue.shade50,
)
Example with default style:
NodeWidget<MyData>.defaultStyle(
node: myNode,
connections: connections,
onPortTap: handlePortTap,
)
See also:
- Node, the data model for nodes
- NodeTheme, which defines default styling
- PortWidget, which renders individual ports
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- NodeWidget
- Available extensions
Constructors
-
NodeWidget({Key? key, required Node<
T> node, Widget? child, NodeShape? shape, List<Connection> connections = const [], void onPortTap(String nodeId, String portId, bool isOutput)?, void onPortHover(String nodeId, String portId, bool isHover)?, void onNodeTap(String nodeId)?, void onNodeDoubleTap(String nodeId)?, void onNodeMouseEnter(String nodeId)?, void onNodeMouseLeave(String nodeId)?, void onNodeContextMenu(String nodeId, Offset position)?, ({bool isOutput, String nodeId, String portId})? hoveredPortInfo, Color? backgroundColor, Color? selectedBackgroundColor, Color? borderColor, Color? selectedBorderColor, double? borderWidth, double? selectedBorderWidth, BorderRadius? borderRadius, EdgeInsets? padding}) -
Creates a node widget with optional custom content.
const
-
NodeWidget.defaultStyle({Key? key, required Node<
T> node, NodeShape? shape, List<Connection> connections = const [], void onPortTap(String nodeId, String portId, bool isOutput)?, void onPortHover(String nodeId, String portId, bool isHover)?, void onNodeTap(String nodeId)?, void onNodeDoubleTap(String nodeId)?, void onNodeMouseEnter(String nodeId)?, void onNodeMouseLeave(String nodeId)?, void onNodeContextMenu(String nodeId, Offset position)?, ({bool isOutput, String nodeId, String portId})? hoveredPortInfo, Color? backgroundColor, Color? selectedBackgroundColor, Color? borderColor, Color? selectedBorderColor, double? borderWidth, double? selectedBorderWidth, BorderRadius? borderRadius, EdgeInsets? padding}) -
Creates a node widget with default content layout.
const
Properties
- backgroundColor → Color?
-
Custom background color.
final
- borderColor → Color?
-
Custom border color.
final
- borderRadius → BorderRadius?
-
Custom border radius.
final
- borderWidth → double?
-
Custom border width.
final
- child → Widget?
-
Optional custom widget to display as node content.
final
-
connections
→ List<
Connection> -
List of connections for determining which ports are connected.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hoveredPortInfo → ({bool isOutput, String nodeId, String portId})?
-
Information about the currently hovered port.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
node
→ Node<
T> -
The node data model to render.
final
- onNodeContextMenu → void Function(String nodeId, Offset position)?
-
Callback invoked on secondary tap (right-click/long-press) for context menu.
final
- onNodeDoubleTap → void Function(String nodeId)?
-
Callback invoked when the node is double-tapped.
final
- onNodeMouseEnter → void Function(String nodeId)?
-
Callback invoked when mouse enters the node.
final
- onNodeMouseLeave → void Function(String nodeId)?
-
Callback invoked when mouse leaves the node.
final
- onNodeTap → void Function(String nodeId)?
-
Callback invoked when the node is tapped.
final
- onPortHover → void Function(String nodeId, String portId, bool isHover)?
-
Callback invoked when a port hover state changes.
final
- onPortTap → void Function(String nodeId, String portId, bool isOutput)?
-
Callback invoked when a port is tapped.
final
- padding → EdgeInsets?
-
Custom padding inside the node.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedBackgroundColor → Color?
-
Custom background color for selected state.
final
- selectedBorderColor → Color?
-
Custom border color for selected state.
final
- selectedBorderWidth → double?
-
Custom border width for selected state.
final
- shape → NodeShape?
-
Optional shape for the node.
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