snap method
Future<void>
snap({
- required String followerId,
- required String targetId,
- required SnapEdge followerEdge,
- required SnapEdge targetEdge,
- SnapAlignment alignment = SnapAlignment.center,
- double gap = 0,
- SnapConfig config = const SnapConfig(),
Snap a follower palette to a target palette.
The follower will be positioned relative to the target's edge and will follow the target's movement.
Implementation
Future<void> snap({
required String followerId,
required String targetId,
required SnapEdge followerEdge,
required SnapEdge targetEdge,
SnapAlignment alignment = SnapAlignment.center,
double gap = 0,
SnapConfig config = const SnapConfig(),
}) async {
if (followerId.isEmpty || targetId.isEmpty) {
debugPrint('[SnapClient] snap() called with empty ID — ignoring');
return;
}
if (followerId == targetId) {
debugPrint('[SnapClient] snap() called with self-snap — ignoring');
return;
}
await send<void>('snap', params: {
'followerId': followerId,
'targetId': targetId,
'followerEdge': followerEdge.name,
'targetEdge': targetEdge.name,
'alignment': alignment.name,
'gap': gap,
'config': config.toMap(),
});
}