I'm using webview_flutter.
Is there anyway I can preload a webview widget when the app starts, and reuse the same widget multiple times in the app?
WebView webview = buildWebview();
Widget getWebview() {
return webview;
}
Widget buildWebview() {
return WebView(
key: GlobalKey(),
onWebViewCreated: (WebViewController webViewController) {
print("WebView is Created");
},
...
);
}
This is what I tried, but it seems the WebView is created when the widget is shown on the screen, not when the app starts. And when I call getWebview() again, WebView is created again.
nice initiate and idea.
You can actually do this
In the main.dart file call this class. this will make the app start the app with your preferred webview every time the app is launched.
And for reusing the class, again and again, create another class and load this webview. Then call or import and use this class whenever needed