ConnectionStyle class abstract
Abstract base class for connection styles.
Single Responsibility: Create Segments
A connection style has ONE job: create path segments from parameters. That's it. Everything else (path generation, hit testing, bend points) is derived from segments using utility methods.
Architecture
final result = style.createSegments(params); // Call ONCE
↓
├─→ style.buildPath(result.start, result.segments) → Path
├─→ style.buildHitTestRects(result.start, result.segments, tolerance) → List<Rect>
└─→ style.extractBendPoints(result.start, result.segments) → List<Offset>
Usage
Callers (like ConnectionPathCache) should:
- Call
createSegments(params)ONCE to get the segments - Store/cache the segments
- Use static utility methods to derive path, hit test rects, etc.
Example Implementation
class MyConnectionStyle extends ConnectionStyle {
@override
String get id => 'my-style';
@override
String get displayName => 'My Style';
@override
({Offset start, List<PathSegment> segments}) createSegments(
ConnectionPathParameters params,
) {
// Calculate waypoints
final waypoints = WaypointBuilder.calculateWaypoints(...);
// Convert to segments
final segments = WaypointBuilder.waypointsToSegments(waypoints);
return (start: params.start, segments: segments);
}
}
- Implementers
- Available extensions
Constructors
- ConnectionStyle()
-
const
Properties
- defaultHitTolerance → double
-
Default hit tolerance for this connection style.
Some styles may need different tolerances based on their geometry.
no setter
- displayName → String
-
Human-readable display name
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
Unique identifier for this connection style
no setter
- isBuiltIn → bool
-
Available on ConnectionStyle, provided by the ConnectionStyleExtension extension
Check if this is a built-in connection styleno setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildHitTestPath(
List< Rect> rects) → Path - Builds a hit test path from rectangle bounds.
-
buildHitTestRects(
Offset start, List< PathSegment> segments, double tolerance) → List<Rect> - Builds hit test rectangles from segments.
-
buildPath(
Offset start, List< PathSegment> segments) → Path - Builds a Path from segments.
-
createSegments(
ConnectionPathParameters params) → ({List< PathSegment> segments, Offset start}) - Creates the path segments for this connection.
-
extractBendPoints(
Offset start, List< PathSegment> segments) → List<Offset> - Extracts bend points from segments.
-
isEquivalentTo(
ConnectionStyle other) → bool - Check if two connection styles are equivalent. This is used for caching decisions and theme comparisons.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override