SnapPlugin class
A plugin that manages snap behavior through a delegate chain.
This plugin wraps a SnapDelegateChain and registers itself as the controller's snap delegate. Delegates are processed in order, with the first delegate to snap an axis "winning" that axis.
Master Enable Switch
The plugin has an enabled property that acts as a master switch for all snapping. When disabled (the default), no snapping occurs. Toggle with the 'N' key or programmatically:
snapPlugin.toggle(); // Toggle with N key
snapPlugin.enabled = true; // Enable programmatically
Default Setup
By default, include GridSnapDelegate for grid snapping:
SnapPlugin([
GridSnapDelegate(gridSize: 20.0),
])
With Alignment Guides
Add alignment snap delegates with higher priority:
SnapPlugin([
SnapLinesDelegate(), // Priority 1: alignment guides
GridSnapDelegate(gridSize: 20.0), // Priority 2: grid snap fallback
])
- Inheritance
-
- Object
- NodeFlowPlugin
- SnapPlugin
- Implemented types
Constructors
-
SnapPlugin(List<
SnapDelegate> delegates, {bool enabled = false})
Properties
-
delegates
→ List<
SnapDelegate> -
The delegates in this plugin's chain.
no setter
- enabled ↔ bool
-
Whether snapping is enabled globally.
getter/setter pair
- gridSnapDelegate → GridSnapDelegate?
-
Gets the GridSnapDelegate from the chain, if present.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Unique identifier for this plugin.
no setteroverride
- layerPosition → LayerPosition
-
The position where this layer should be rendered.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
attach(
NodeFlowController controller) → void -
Called when the plugin is attached to a controller.
override
-
buildLayer(
BuildContext context) → Widget? - Builds the layer widget to render.
-
detach(
) → void -
Called when the plugin is detached from the controller.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDragEnd(
) → void -
Called when the drag operation ends.
override
-
onDragStart(
Set< String> nodeIds) → void -
Called when a node drag operation starts.
override
-
onEvent(
GraphEvent event) → void -
Called when a graph event occurs.
override
-
snapPosition(
{required Set< String> draggedNodeIds, required Offset intendedPosition, required Rect visibleBounds}) → SnapResult -
Calculate the snapped visual position from the intended position.
override
-
toggle(
) → void - Toggles the enabled state.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited