Port class
Represents a connection point on a node in the flow editor.
A Port defines where and how connections can be made to a node. Each port has a position, appearance, and behavior that determines how it interacts with connections in the flow editor.
Ports can be configured as sources (outputs), targets (inputs), or both, and support various customization options including:
- Visual appearance (shape, size, position)
- Connection behavior (single/multiple connections, max connections)
- Interactive states (hoverable, connectable)
Example:
// Create a simple output port
final outputPort = Port(
id: 'output-1',
name: 'Result',
type: PortType.source,
position: PortPosition.right,
);
// Create an input port with multiple connections allowed
final inputPort = Port(
id: 'input-1',
name: 'Data',
type: PortType.target,
position: PortPosition.left,
multiConnections: true,
maxConnections: 5,
tooltip: 'Accepts up to 5 connections',
);
// Create a bidirectional port with custom styling
final bothPort = Port(
id: 'io-1',
name: 'I/O',
type: PortType.both,
position: PortPosition.top,
shape: MarkerShapes.diamond,
size: Size(12, 12),
offset: Offset(10, 0),
);
- Annotations
-
- @JsonSerializable.new()
Constructors
- Port({required String id, required String name, bool multiConnections = false, PortPosition position = PortPosition.left, Offset offset = Offset.zero, PortType type = PortType.both, MarkerShape? shape, Size? size, String? tooltip, bool isConnectable = true, int? maxConnections, bool showLabel = false})
-
Creates a port with the specified configuration.
const
-
Port.fromJson(Map<
String, dynamic> json) -
Creates a Port instance from a JSON map.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Unique identifier for this port.
final
- isConnectable → bool
-
Whether connections can be made to/from this port.
final
- isSource → bool
-
Whether this port can act as a source (output) for connections.
no setter
- isTarget → bool
-
Whether this port can act as a target (input) for connections.
no setter
- maxConnections → int?
-
Maximum number of connections allowed for this port.
final
- multiConnections → bool
-
Whether this port can accept multiple connections.
final
- name → String
-
Display name for the port.
final
- offset → Offset
-
Position offset that specifies where the CENTER of the port should be.
final
- position → PortPosition
-
The position of the port relative to its node.
final
-
props
→ List<
Object?> -
The list of properties that will be used to determine whether
two instances are equal.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → MarkerShape?
-
The visual shape of the port.
final
- showLabel → bool
-
Whether to display the port's label.
final
- size → Size?
-
The size of the port in logical pixels.
final
- stringify → bool?
-
If set to
true, thetoStringmethod will be overridden to output this instance'sprops.no setterinherited - tooltip → String?
-
Optional tooltip text displayed when hovering over the port.
final
- type → PortType
-
The directionality of the port.
final
Methods
-
copyWith(
{String? id, String? name, bool? multiConnections, PortPosition? position, Offset? offset, PortType? type, MarkerShape? shape, Size? size, IconData? icon, String? tooltip, bool? isConnectable, int? maxConnections, bool? showLabel}) → Port - Creates a copy of this port with the specified properties replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts this port to a JSON map.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited