@@ -239,27 +239,23 @@ class ChatBoxState extends State<ChatBox> {
239
239
},
240
240
shouldOverrideUrlLoading: (InAppWebViewController controller, NavigationAction navigationAction) async {
241
241
if (navigationAction.navigationType == NavigationType .LINK_ACTIVATED ) {
242
- var shouldOpenBrowser = true ;
243
-
244
242
if (widget.onUrlNavigation != null ) {
245
243
// The onUrlNavigation function has been defined, so let's see if we should open the browser or not
246
244
if (widget.onUrlNavigation !(UrlNavigationRequest (navigationAction.request.url! .rawValue)) == UrlNavigationAction .deny) {
247
- shouldOpenBrowser = false ;
245
+ return NavigationActionPolicy . CANCEL ;
248
246
}
249
247
}
250
248
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 ;
259
255
}
260
256
}
261
257
262
- return NavigationActionPolicy .CANCEL ;
258
+ return NavigationActionPolicy .ALLOW ;
263
259
},
264
260
);
265
261
}
0 commit comments