0

I am trying open a link on Google pixel API 30 Emulator but keep on getting error. Have tried flutter clean, restarted app.

Dependency:-

url_launcher: ^6.0.3

Code:-

  InkWell(
onTap:() => _launchURL("https://google.com"),
child: Image.asset("assets/images/googleIcon.jpg")
),

_launchURL(String url) async {
if (await canLaunch(url)) {
  await launch(url);
} else {
  throw 'Could not launch $url';
}

}

Error:-

   Unhandled Exception: Could not launch https://google.com
GAGAN SINGH
  • 261
  • 2
  • 17

1 Answers1

0

Add a URI class since url_launcher recommends encoding the URLs as URI. Link to Doc

final Uri _faireGitHubUri = Uri.https('google.com', '/');

    InkWell(
onTap:() => _launchURL(_websiteUri.toString()),
child: Image.asset("assets/images/googleIcon.jpg")
),
msyagami
  • 49
  • 1
  • 1
  • 4