fromCoords static method

Geolocation? fromCoords(
  1. String? coords, [
  2. bool onlyWithCardinals = false
])

Implementation

static Geolocation? fromCoords(String? coords,
    [bool onlyWithCardinals = false]) {
  if (coords == null) return null;
  coords = coords.trim();
  if (coords.isEmpty) return null;

  var parts = coords.split(RegExp(r'\s+'));
  if (parts.length < 2) return null;

  var lat = parseLatitudeOrLongitudeValue(parts[0], onlyWithCardinals);
  var long = parseLatitudeOrLongitudeValue(parts[1], onlyWithCardinals);

  return lat != null && long != null ? Geolocation(lat, long) : null;
}