forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webview_flutter_android][webview_flutter_wkwebview] Fixes bug where …
…`PlatformWebViewWidget` doesn't rebuild when the controller changes (flutter#4533) In a scenario where a `WebViewWidget` was updated with a new `WebViewController`, the native `WebView` from the new controller would not be shown. e.g. ```dart class WebViewExample extends StatefulWidget { const WebViewExample({super.key}); @OverRide State<WebViewExample> createState() => _WebViewExampleState(); } class _WebViewExampleState extends State<WebViewExample> { late WebViewController controller; @OverRide void initState() { super.initState(); controller = WebViewController() ..loadRequest(Uri.parse('https://flutter.dev')); } @OverRide Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Flutter Simple Example')), body: WebViewWidget(controller: controller), floatingActionButton: FloatingActionButton( onPressed: () { setState(() { controller = WebViewController() ..loadRequest(Uri.parse('https://google.com')); }); }, child: const Icon(Icons.add), ), ); } } ``` From testing, the `WebViewWidget` would continue showing the original `WebViewController` and eventually freeze the PlatformView preventing button presses. This is because the PlatformView widget only creates the native PlatformView once and doesn't recreate it when the creation parameters change (as expected). This adds a default `key` to the `PlatformWebViewWidget` that is used to indicate when the underlying widget needs to be removed and recreated. See https://api.flutter.dev/flutter/widgets/Widget/key.html
- Loading branch information
1 parent
2481d92
commit 26889ce
Showing
8 changed files
with
197 additions
and
35 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/webview_flutter/webview_flutter_android/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters