fluttercommunity / flutter_webview_plugin

Community WebView Plugin - Allows Flutter to communicate with a native WebView.
https://pub.dev/packages/flutter_webview_plugin
Other
1.48k stars 929 forks source link

flutter_webview_plugin not switching when stored inside of indexed stack #844

Open RohanDani2 opened 3 years ago

RohanDani2 commented 3 years ago

I am new to flutter and am developing a flutter app that has the ability to switch between multiple tabs where each tab is its own separate widget. To accomplish this, I am using a bottom navigation bar. I also need the widgets to not be reset every time the tab gets switched, so I am storing each widget in an indexedStack instead of an array. My issue is that when I run the app, the webview (from flutter_webview_plugin, NOT webview_flutter) will just stay on the screen and I cannot switch out of it. Switching between all other widgets works fine. I can still press buttons on the bottom navigation bar, so it will have a different button highlighted for one of the other widgets, but still be on the webview. I can still use the webview when it is like this. I don't have this issue when I just use an array, but the widgets reset themselves each time a new one is selected, which is not my desired behavior. Below is how I am switching between the tabs.

The code is here: https://stackoverflow.com/questions/64360212/flutter-webview-plugin-not-switching-when-stored-inside-of-indexed-stack

What can I do to get my app to properly switch in and out of the widget that displays the webview? If I shouldn't use an indexedStack, what should I use instead so the widgets don't reset every time the tab gets switched?