Home > OS >  Open a Apple map on flutter gives invalid URL scheme
Open a Apple map on flutter gives invalid URL scheme

Time:02-01

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

CodePudding user response:

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

  •  Tags:  
  • Related