Following all tutorials and articles online, everybody is using launch()
function from the known url_launcher plugin to open links, so i used it in my application to open messenger, whatsApp, and directcalls as follows:
_directCall() {
launch('tel:00962785522213');
}
//Open WhatsApp
_launchWhatsapp() {
launch("https://wa.me/ 962797809910");
}
//Open Messenger
_openMessenger() {
launch("http://m.me/amr.al.shugran");
}
but unfortunately the launch method is no longer used and i have to use launchUrl()
so i would be thankful if anyone could tell us how to use this function at the same context am using launch()
.
CodePudding user response:
You need to use
//Open Messenger
_openMessenger() {
launchUrl(Uri.parse("http://m.me/amr.al.shugran"));
}
CodePudding user response:
Try it
Future _launchUrl(url) async {
if (!await launchUrl(Uri.parse(url))) {
throw 'Could not launch $url';
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Test'),
),
body: OutlinedButton(
onPressed: () async {
_launchUrl('www.google.com');
},
child: const Text('Open'),
),
);
}