Kishor Bhalerao
Kishor Bhalerao

Reputation: 31

Open a Apple map on flutter gives invalid URL scheme

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');
                       }```

Upvotes: 3

Views: 540

Answers (1)

Neeraj
Neeraj

Reputation: 41

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

Upvotes: 2

Related Questions