commit | 26889ce846ad739968e942482a64ade7134b7495 | [log] [tgz] |
---|---|---|
author | Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> | Tue Jul 25 10:33:22 2023 -0400 |
committer | GitHub <noreply@github.com> | Tue Jul 25 14:33:22 2023 +0000 |
tree | eb725082c85f88aadd27ecceb79c251ec75c26ab | |
parent | 2481d92950890edbd1effa41bcd7fd3579d63dab [diff] |
[webview_flutter_android][webview_flutter_wkwebview] Fixes bug where `PlatformWebViewWidget` doesn't rebuild when the controller changes (#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
This repo is a companion repo to the main flutter repo. It contains the source code for Flutter's first-party packages (i.e., packages developed by the core Flutter team). Check the packages
directory to see all packages.
These packages are also available on pub.
Please file any issues, bugs, or feature requests in the main flutter repo. Issues pertaining to this repository are labeled “package”.
If you wish to contribute a new package to the Flutter ecosystem, please see the documentation for developing packages. You can store your package source code in any GitHub repository (the present repo is only intended for packages developed by the core Flutter team). Once your package is ready you can publish to the pub repository.
If you wish to contribute a change to any of the existing packages in this repo, please review our contribution guide, and send a pull request.
These are the packages hosted in this repository: