0

I am trying to open Netflix in flutter using WebView which is a very common plugin.

I am able to navigate to netflix.com and even login but when I try to click on a movie or tv show, it returns this error(in the screenshot).
Why is "intent//:" joining at the front of the URL and how can I fix this error?

The code for the WebView is pretty basic.

import 'package:webview_flutter/webview_flutter.dart';

class Browser extends StatefulWidget {
  const Browser({Key? key}) : super(key: key);

  @override
  _BrowserState createState() => _BrowserState();
}

class _BrowserState extends State<Browser> {
  late WebViewController controller;
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: WebView(
          initialUrl: "https://www.netflix.com/browse",
          javascriptMode: JavascriptMode.unrestricted,
        ),
      ),
    );
  }
}

The Screenshot with the error.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Spidey Verse
  • 1
  • 1
  • 2
  • The problem is that the website detects that the current device is an Android device and it tries to navigate the user to the Netflix app, hence the `intent://` tag. You can try loading the URL by adding a different user agent. – Darshan Dec 28 '21 at 19:46
  • How do I do that?.....Do I have to use if else to remove ```intent//:``` from the link or is there any other way? – Spidey Verse Dec 29 '21 at 07:39
  • You can try replacing `intent://` with `https://`. – Darshan Dec 29 '21 at 07:41
  • Ya.....How do I replace it? – Spidey Verse Dec 29 '21 at 08:14
  • You might wanna check this, replace the `intent` with `https` in the callback: https://stackoverflow.com/a/37145639/6819340 – Darshan Dec 29 '21 at 14:01
  • @DarShan I saw this solution earlier but this is in java......Can you help me understand what is going on in the code? – Spidey Verse Dec 30 '21 at 13:13

1 Answers1

-1
<application
  ....
  android:usesCleartextTraffic="true"
....>

and

<uses-permission android:name="android.permission.INTERNET" />
Hamza Siddiqui
  • 675
  • 5
  • 12