Open a Apple map on flutter gives invalid URL scheme

Viewed 141

In flutter code to open maps is like this. It is working on google but not launching apple map url. Might be small mistake or missing something

                       String addrs = '';
                       addrs = '###';
                       String googleUrl =
                           'comgooglemaps://?q=${Uri.encodeComponent(addrs)}&center=lat,lng';
                       String appleUrl =
                           'https://maps.apple.com/?q=${addrs}&sll=lat,lng';
                       if (await canLaunch("comgooglemaps://")) {
                         print('launching com googleUrl');
                         await launch(googleUrl);
                       } else if (await canLaunch(appleUrl)) {
                         print('launching apple url');
                         await launch(appleUrl);
                       } else {
                         print('Could not launch url');
                       }```
1 Answers

Please encode the URL for apple maps as you have done for google maps.

Related