I achieved this thanks to the code below while using Webview
navigationDelegate: (NavigationRequest request) {
if (request.url.startsWith('https://google.com/')) {
print('allowing navigation to $request');
return NavigationDecision.navigate;
} else {
print('Opening Default Browser');
launchURL(request.url); // to open browser
return NavigationDecision.prevent;
}
},
But when I used inappwebview, the above code didn't work. What should I do to open external web addresses in the browser when using Inappwebview?
InAppWebView: https://pub.dev/packages/flutter_inappwebview
You can use
shouldOverrideUrlLoading:()
for InAppWebView.