ConnectionLabel class
Represents a label that can be positioned on a connection path.
Each label has:
- text: The label content to display
- anchor: Position along the path (0.0 = source, 1.0 = target, 0.5 = center)
- offset: Perpendicular offset from the path (positive = one side, negative = other)
- id: Optional identifier for programmatic access
All properties are observable for reactive UI updates.
Usage Example
// Using factory constructors (recommended)
final startLabel = ConnectionLabel.start(text: 'Start');
final centerLabel = ConnectionLabel.center(text: 'Processing', offset: 5.0);
final endLabel = ConnectionLabel.end(text: 'Complete');
// Or using the default constructor with explicit anchor
final customLabel = ConnectionLabel(text: 'Custom', anchor: 0.25, offset: -10.0);
- Annotations
-
- @JsonSerializable.new()
Constructors
- ConnectionLabel({required String text, double anchor = ConnectionAnchor.center, double offset = 0.0, String? id})
- ConnectionLabel.center({required String text, double offset = 0.0, String? id})
-
Creates a label positioned at the center of the connection (anchor 0.5).
factory
- ConnectionLabel.end({required String text, double offset = 0.0, String? id})
-
Creates a label positioned at the end of the connection (anchor 1.0).
factory
-
ConnectionLabel.fromJson(Map<
String, dynamic> json) -
Creates a ConnectionLabel from JSON
factory
- ConnectionLabel.start({required String text, double offset = 0.0, String? id})
-
Creates a label positioned at the start of the connection (anchor 0.0).
factory
Properties
- anchor → double
-
The position along the connection path (0.0 to 1.0)
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Unique identifier for this label
Useful for programmatically finding and updating specific labels
final
- offset → double
-
The perpendicular offset from the connection path
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- text → String
-
The text content of the label
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts this ConnectionLabel to JSON
-
toString(
) → String -
A string representation of this object.
override
-
update(
{String? text, double? anchor, double? offset}) → void - Updates multiple properties at once
-
updateAnchor(
double anchor) → void - Updates the anchor position (0.0 to 1.0)
-
updateOffset(
double offset) → void - Updates the perpendicular offset
-
updateText(
String text) → void - Updates the label text
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited