0

I am trying to update the url or somehow navigate to another page if the url has "intent" which automatically comes when I navigate to any movie on netflix. Here is the code-

          navigationDelegate: (NavigationRequest request) {
            if (request.url.substring(0, 6) == "intent") {
              print("its intent");
              setState(() {
                currentUrl = "https${request.url.substring(6)}";
                print(currentUrl);
              });
            } else {
              print("Still way ahead");
            }
            //I want to navigate to currentUrl but Navigate.Decision.navigate navigates to request.url
            return NavigationDecision.navigate;
          },
          
          initialUrl: currentUrl,
          javascriptMode: JavascriptMode.unrestricted,)```


Here in the navigationDelegate I want to update the url but since request.url is a final,
 I cannot do so......Is there any other way I can navigate to currentUrl


I also tried another method-

onPageFinished: (url) {
            if (url.substring(0, 6) == "intent") {
              print("its intent");
          setState(() {
                currentUrl = "https://www.google.com/";
              });
              controller.reload();
            } else {
              print("Still way ahead");

            }
          }

The problem is that controller.reload is just going back to the previous url 
0

1 Answer 1

2

controller.reload() will load the current loaded url in the webview.
You should use controller.loadUrl("your_new_url").

More info. about the method here: https://pub.dev/documentation/webview_flutter/latest/webview_flutter/WebViewController/loadUrl.html

Sign up to request clarification or add additional context in comments.

4 Comments

I even tried that but it is not loading......Instead I am getting the same message again and again in the console........Where should I call this method?
It is working when clicking on a button but otherwise its not
Check if the current URL in the onPageFinished callback contains intent, use controller.loadUrl("your_new_url") there.
Actually I just found out that you cannot play Netflix on Flutter WebViews

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.