resolveScaleArena function

ActiveGesture? resolveScaleArena({
  1. required double scale,
  2. required Map<ScaleStart, ScaleGesture> registered,
  3. double minDelta = 0.01,
})

Resolves a scale gesture from the registered map for the current scale magnitude. Returns the first eligible entry, or null if scale is below the commit threshold or no gesture qualifies.

Implementation

ActiveGesture? resolveScaleArena({
  required double scale,
  required Map<ScaleStart, ScaleGesture> registered,
  double minDelta = 0.01,
}) {
  if ((scale - 1.0).abs() < minDelta) return null;

  final eligible = <ScaleStart>{ScaleStart.any};
  if (scale > 1.0) eligible.add(ScaleStart.expand);
  if (scale < 1.0) eligible.add(ScaleStart.shrink);

  for (final entry in registered.entries) {
    if (eligible.contains(entry.key)) return (start: entry.key, gesture: entry.value);
  }
  return null;
}