snap method

Future<void> snap({
  1. required String followerId,
  2. required String targetId,
  3. required SnapEdge followerEdge,
  4. required SnapEdge targetEdge,
  5. SnapAlignment alignment = SnapAlignment.center,
  6. double gap = 0,
  7. 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(),
  });
}