PortWidget<T> class

Widget for rendering a port on a node.

The PortWidget displays a port with its shape, color, and optional label. It supports property overrides at both widget and model levels.

Property Cascade (lowest to highest priority)

Properties are resolved in this order of precedence:

  1. Theme values (from PortTheme) - lowest priority
  2. Widget-level overrides (constructor parameters)
  3. Model-level values (from Port) - highest priority

For example, port size is resolved as:

  • port.size (if different from default) → widget sizetheme.size

Example with overrides:

PortWidget(
  port: myPort, // port.size = 12.0 takes precedence
  theme: PortTheme.light,
  color: Colors.blue, // Override idle color
  connectedColor: Colors.green, // Override connected color
)
Inheritance

Constructors

PortWidget({Key? key, required Port port, required PortTheme theme, required NodeFlowController<T> controller, required String nodeId, required bool isOutput, required Rect nodeBounds, bool isConnected = false, ValueChanged<Port>? onTap, VoidCallback? onDoubleTap, void onContextMenu(Offset globalPosition)?, ValueChanged<(Port, bool)>? onHover, double snapDistance = 8.0, Size? size, Color? color, Color? connectedColor, Color? highlightColor, Color? highlightBorderColor, Color? borderColor, double? borderWidth})
const

Properties

borderColor Color?
Override for the border color.
final
borderWidth double?
Override for the border width.
final
color Color?
Override for the idle port color.
final
connectedColor Color?
Override for the connected port color.
final
controller NodeFlowController<T>
Controller for connection drag handling.
final
hashCode int
The hash code for this object.
no setterinherited
highlightBorderColor Color?
Override for the highlight border color.
final
highlightColor Color?
Override for the highlight fill color (when port is highlighted during drag).
final
isConnected bool
final
isOutput bool
Whether this is an output port.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
nodeBounds Rect
The bounds of the parent node in graph coordinates (for connection start).
final
nodeId String
The ID of the node containing this port.
final
onContextMenu → void Function(Offset globalPosition)?
Callback invoked when the port is right-clicked (context menu).
final
onDoubleTap VoidCallback?
Callback invoked when the port is double-tapped.
final
onHover ValueChanged<(Port, bool)>?
Callback invoked when hover state changes.
final
onTap ValueChanged<Port>?
Callback invoked when the port is tapped.
final
port Port
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size Size?
Override for the port size. Resolution: port.size → widget.size → theme.size
final
snapDistance double
Distance around the port that expands the hit area for easier targeting.
final
theme PortTheme
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<PortWidget<T>>
Creates the mutable state for this widget at a given location in the tree.
override
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

Operators

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