parseXY function

(double, double)? parseXY(
  1. String raw
)

Parses an "x,y" coordinate string into a (double, double) tuple, or returns null if the input is malformed.

Used by CLI adapters that accept coordinate flags like --at, --from, --to. The associated error message format is the adapter's responsibility.

Implementation

(double, double)? parseXY(String raw) {
  final parts = raw.split(',');
  if (parts.length != 2) return null;
  final x = double.tryParse(parts[0].trim());
  final y = double.tryParse(parts[1].trim());
  if (x == null || y == null) return null;
  return (x, y);
}