flutter-maps-launcher icon indicating copy to clipboard operation
flutter-maps-launcher copied to clipboard

Crash when opening a maps query using ios

Open NZPIF opened this issue 1 year ago • 4 comments

Looking for a fix for this...

Code is relatively simple, the maps query is set up correctly and the location found but this error is thrown on both a device and simulator:

Exception has occurred.
PlatformException (PlatformException(Error, Error while launching https://maps.apple.com/?q=Palmerston+North+Bridge+Club%0D%0ACorner+Cook+and+Cuba+Streets%2C+Palmerston+North, null, null))

The maps app does open and the search is run but on returning to the app it's frozen with the error showing in the editor.

The class was stable and no errors until the maps launcher was added.

class EventVenueRow extends StatelessWidget {
  const EventVenueRow(this.label, this.icon, this.value, {Key? key})
      : super(key: key);

  final String label;
  final IconData icon;
  final String value;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
          children: [
            eventIcon(label, icon),
            eventLabel(label),
            Expanded(
              child: GestureDetector(
                onTap: () => MapsLauncher.launchQuery(value),
                child: Semantics(
                  label: 'Event $label is $value',
                  child: Text(
                    value,
                    style: const TextStyle(
                      fontSize: 15,
                      fontWeight: FontWeight.bold,
                      overflow: TextOverflow.visible,
                    ),
                  ),
                ),
              ),
            ),
          ]),
    );
  }
}

The app is using url launcher successfully.

Some details about my setup: Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git Framework • revision f468f3366c (2 weeks ago) • 2023-07-12 15:19:05 -0700 Engine • revision cdbeda788a Tools • Dart 3.0.6 • DevTools 2.23.1

from pubspec.yaml url_launcher: ^6.1.12 maps_launcher: ^2.2.0

NZPIF avatar Aug 01 '23 10:08 NZPIF

FWIW we can't use https://github.com/mattermoran/map_launcher because we don't have lat/lng and need the "query" ability.

NZPIF avatar Aug 04 '23 03:08 NZPIF

I'm experiencing the same issue. I'm using the same versions of url_launcher and maps_launcher as above. I tried changing the url_launcher to 6.1.0 (as is the earliest version in the maps pubspec) but it still is crashing.

floralWallpaper avatar Aug 09 '23 16:08 floralWallpaper

I've done some digging and the problem isn't with this package, it's a problem within url_launcher

Ref: https://stackoverflow.com/questions/76934676/flutter-url-launcher-crashes-opening-apple-maps-on-ios

For my purposes, I'm probably going to fork url_launcher and ignore the error and keep checking whenever url_launcher is upgraded.

I did see some threads talking about how maps_launcher failed if there were unusual characters in the string so I have this in my code but it doesn't seem to make a difference:

  String get cleanValue => value.replaceAll(RegExp(r'[^\w ]+'), ' ');
  String get cleanValue2 => cleanValue.replaceAll("  ", " ");

sarahk avatar Aug 20 '23 23:08 sarahk

I was able to implement url_launcher without a problem... I'm thinking url_launcher made a change at some point and this package's implementation needs to be updated possibly. I tried falling back to older versions of url_launcher for this package but still couldn't get it to work.

floralWallpaper avatar Aug 21 '23 13:08 floralWallpaper