skip to Main Content
Future<void> _openURL(String url) async {
  if (await canLaunch(url)) {
    await launch(url, forceSafariVC: false, forceWebView: true);
   }

ListTile(
   title: Text('Google'),
   onTap: () {
      _openURL('https://www.google.de/');
   },
);

But no matter what url i want to open, i get the error ‘Cant open URL’

2

Answers


  1. I don’t know which package are you using for url, but for me the flutter package works fine

    Then, just launch the url like this:

    _launchUrl(Uri.parse('https://www.google.de/'));
    
    Future<void> _launchUrl(Uri url) async {
      if (!await launchUrl(url)) {
        throw Exception('Could not launch $url');
      }
    }}
                              
    

    Maybe your error depends on the fact that you’re using a String and not a Uri type in the function.
    Try using the package i told you with the function i provided you.

    Login or Signup to reply.
  2. try adding this Uri.parse(url)

    await launch(Uri.parse(url), forceSafariVC: false, forceWebView: true);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search