Mill3r
Mill3r

Reputation: 544

Open Webpage in Webview with dynamic url parameters [Flutter - WebViewScaffold]

I am trying to open a webpage in the webview but with a dynamic url in Flutter WebViewScaffold widget.

               WebviewScaffold(
                  url: "https://www.svstepaper.com/api/web-view/$api_token/$device_id/$getDate/$getPage?",
                  withJavascript: true,
                  // run javascript
                  withZoom: true,
                  hidden: true,
                  clearCache: true,
                  clearCookies: true,
                  displayZoomControls: true,
                  bottomNavigationBar: BottomNavigationBar(
                    type: BottomNavigationBarType.fixed,
                    onTap: (int index) {
                      setState(() {
                        print(index);
                        if (index == 0) {
                          flutterWebviewPlugin.goBack();
                        } else if (index == 1) {
                          flutterWebviewPlugin.reload();
                        } else if (index == 2) {
                          flutterWebviewPlugin.goForward();
                        }
                      });
                    },
                    items: [
                      BottomNavigationBarItem(
                        icon: Icon(Icons.arrow_back),
                        title: Text('Back'),
                      ),
                      BottomNavigationBarItem(
                        icon: Icon(Icons.refresh),
                        title: Text('Refresh'),
                      ),
                      BottomNavigationBarItem(
                        icon: Icon(Icons.arrow_forward),
                        title: Text('Forword'),
                      ),
                    ],
                  ),
                  initialChild: Container(
                    // but if you want to add your own waiting widget just add InitialChild
                    color: Colors.white,
                    child: const Center(
                      child: Text('waiting...'),
                    ),
                  ),
                )

my url is "https://www.svstepaper.com/api/web-view/$api_token/$device_id/$getDate/$getPage?" where i am passing the token, device id, date and page number as parameters.

The URL is correct as i have seen from debugging. When i copy and paste the url from debug console to a browser, it opens correctly but it does not open inside the WebView (gives 404 not found error).

What is wrong here?

Upvotes: 1

Views: 711

Answers (0)

Related Questions