@@ -239,27 +239,23 @@ class ChatBoxState extends State<ChatBox> {
239239 },
240240 shouldOverrideUrlLoading: (InAppWebViewController controller, NavigationAction navigationAction) async {
241241 if (navigationAction.navigationType == NavigationType .LINK_ACTIVATED ) {
242- var shouldOpenBrowser = true ;
243-
244242 if (widget.onUrlNavigation != null ) {
245243 // The onUrlNavigation function has been defined, so let's see if we should open the browser or not
246244 if (widget.onUrlNavigation !(UrlNavigationRequest (navigationAction.request.url! .rawValue)) == UrlNavigationAction .deny) {
247- shouldOpenBrowser = false ;
245+ return NavigationActionPolicy . CANCEL ;
248246 }
249247 }
250248
251- if (shouldOpenBrowser) {
252- if (await launchUrl (navigationAction.request.url! )) {
253- // We launched the browser, so we don't navigate to the URL in the WebView
254- return NavigationActionPolicy .CANCEL ;
255- } else {
256- // We couldn't launch the external browser, so as a fallback we're using the default action
257- return NavigationActionPolicy .ALLOW ;
258- }
249+ if (await launchUrl (navigationAction.request.url! )) {
250+ // We launched the browser, so we don't navigate to the URL in the WebView
251+ return NavigationActionPolicy .CANCEL ;
252+ } else {
253+ // We couldn't launch the external browser, so as a fallback we're using the default action
254+ return NavigationActionPolicy .ALLOW ;
259255 }
260256 }
261257
262- return NavigationActionPolicy .CANCEL ;
258+ return NavigationActionPolicy .ALLOW ;
263259 },
264260 );
265261 }
0 commit comments