isExternalMapsUrl static method

bool isExternalMapsUrl(
  1. String url
)

Returns true if url is a Google Maps URL that should open externally (browser or native Maps app) instead of inside the webview. Excludes the embed API URL so the iframe can load the map.

Implementation

static bool isExternalMapsUrl(String url) {
  if (url.isEmpty) return false;
  final lower = url.toLowerCase();
  // Do not open externally for the embed API (iframe source) — only on user tap to directions etc.
  if (lower.contains('/maps/embed') || lower.contains('maps/embed/')) {
    return false;
  }
  return lower.contains('maps.google.com') ||
      lower.contains('google.com/maps') ||
      lower.startsWith('https://maps.app.goo.gl/') ||
      lower.startsWith('http://maps.app.goo.gl/');
}