targetAt method

ArgosTuningTarget? targetAt(
  1. Offset globalPosition
)

Returns the smallest mounted target containing globalPosition.

Implementation

ArgosTuningTarget? targetAt(Offset globalPosition) {
  ArgosTuningTarget? result;
  var smallestArea = double.infinity;
  for (final entry in _registrations.entries) {
    final target = _snapshotTarget(entry.key, entry.value);
    final bounds = target.bounds;
    if (bounds == null ||
        bounds.isEmpty ||
        !bounds.contains(globalPosition)) {
      continue;
    }
    final area = bounds.width * bounds.height;
    if (area <= smallestArea) {
      smallestArea = area;
      result = target;
    }
  }
  return result;
}