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.output,
position: PortPosition.right,
);
// Create an input port with multiple connections allowed
final inputPort = Port(
id: 'input-1',
name: 'Data',
type: PortType.input,
position: PortPosition.left,
multiConnections: true,
maxConnections: 5,
tooltip: 'Accepts up to 5 connections',
);
// Create a top port with custom styling
final topPort = Port(
id: 'top-1',
name: 'Config',
position: PortPosition.top,
shape: MarkerShapes.diamond,
size: Size(12, 12),
offset: Offset(75, 0), // Centered on a 150px wide node
);
- Annotations
-
- @JsonSerializable.new()
Constructors
- Port({required String id, required String name, bool multiConnections = false, PortPosition position = PortPosition.left, Offset offset = Offset.zero, PortType? type, MarkerShape? shape, Size? size, String? tooltip, bool isConnectable = true, int? maxConnections, bool showLabel = false})
- Creates a port with the specified configuration.
-
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
-
highlighted
→ Observable<
bool> -
Observable for the port's highlighted state.
final
- id → String
-
Unique identifier for this port.
final
- isConnectable → bool
-
Whether connections can be made to/from this port.
final
- isInput → bool
-
Whether this port can act as an input for connections.
no setter
- isOutput → bool
-
Whether this port can act as an output 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