I'v used url_launcher package.
String query = Uri.encodeComponent(Utils.getSelectedStoreAddress());
var appleUrl = 'maps:q=$query';
var googleUrl = 'https://www.google.com/maps/search/?api=1&query=$query';
_launch(appleUrl);
_launch(googleUrl);
Future<void> _launch(String url) async {
await canLaunch(url)
? await launch(url)
: _showSnackBar('could_not_launch_this_app'.tr());
}
Everything were OK until I get this warning:
info: 'canLaunch' is deprecated and shouldn't be used. Use canLaunchUrl instead.
CodePudding user response:
I changed my code as below & everything goes OK:
String query = Uri.encodeComponent(Utils.getSelectedStoreAddress());
Uri appleUrl = Uri.parse('maps:q=$query');
Uri googleUrl = Uri.parse('https://www.google.com/maps/search/?api=1&query=$query');
_launch(appleUrl);
_launch(googleUrl);
Future<void> _launch(Uri url) async {
await canLaunchUrl(url)
? await launchUrl(url)
: _showSnackBar('could_not_launch_this_app'.tr());
}