'Webview disabled to open installed Apps by clicking on link

I have a simple WebView in my Project. The user can google and search for anything. The problem that I have right now is that by clicking on certain links, I get automatically redirected to the specific app (if I have it installed).

Example:

I have the Adidas App on my iPhone and tap on a "Adidas"-Link -> I get redirected to the Adidas app. That should not happen. Instead the link should be opened within my WebView.

This is my webView:

  bool _isLoading = true;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Web View Example'),
      ),
      body: SafeArea(
        child: Column(
          children: [
            Expanded(
              child: WebView(
                initialUrl:
                    'https://www.sneakersnstuff.com/de/product/48276/adidas-4d-futurecraft?country_override=DE&utm_content=cpcadssnscf&gclid=CjwKCAjwoduRBhA4EiwACL5RP4YhIZ818uzJTmO8gKLX3Z6Vvff740OjFsxs2nL0yzf-uGyzW9ak6RoCxyEQAvD_BwE',
                javascriptMode: JavascriptMode.unrestricted,
                onWebViewCreated: (WebViewController webViewController) {
                  _controller = webViewController;
                },
                javascriptChannels: <JavascriptChannel>{
                  _extractDataJSChannel(context),
                },
                onPageStarted: (String url) {
                  setState(() {
                    _isLoading = true;
                  });
                },
                onPageFinished: (String url) {
                  setState(() {
                    _imagesWithSize = [];

                    _currentUrl = url;
                    _isLoading = false;
                  });
                },
              ),
            ),
            Row(
              children: [
                IconButton(
                  onPressed: () {
                    _controller.goBack();
                  },
                  icon: Icon(
                    Icons.arrow_back,
                    size: 50,
                  ),
                ),
                IconButton(
                  onPressed: () {
                    _controller.goForward();
                  },
                  icon: Icon(
                    Icons.arrow_forward,
                    size: 50,
                  ),
                ),
              ],
            ),
            SizedBox(
              height: 20,
            ),
            RoundedCornersTextButton(
              title: 'Google',
              isEnabled: !_isLoading,
              onTap: () async {
                await _controller.loadUrl('https://www.google.com');
              },
            ),
          ],
        ),
      ),
    );
  }

Is there any way to prevent other apps from opening?



Solution 1:[1]

I don't think this is some issue with the webview.

Actually there are a few websites that when you open them, they check if you are using a mobile phone and If that is the case, they also check If you already have the app installed on your device. If that is also true, the mobile app is opened by default.

Can you please go to some other website using the google search (inside webview) and see if the same behaviour exists ?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Divyam Dhadwal