Repository: flutter
Issue: Android | WebViewWidget flickers when loading and resizing another Web View
Labels: platform-android,a: platform-views,p: webview,package,has reproducible steps,P2,team-android,triaged-android,found in release: 3.22

### Steps to reproduce

Given the sample code and running on Android phones/emulators, click the Reload button to Reload the second WebViewWidget.

### Expected results

Second Web View disappears and reappears when it finished loading.

### Actual results

For a brief time, the contents on the second WebView appears on the first WebView. Depending on the dimensions, they could look a little smeared.

### Code sample

<details open><summary>Code sample</summary>

```dart
class WebViewWithWebView extends StatefulWidget {
  @override
  _WebViewWithWebViewState createState() => _WebViewWithWebViewState();
}

class _WebViewWithWebViewState extends State<WebViewWithWebView> {
  bool _isWebReady = false;
  final WebViewController _controllerWeb1 = WebViewController();
  final WebViewController _controllerWeb2 = WebViewController();

  @override
  void initState() {
    super.initState();
    _controllerWeb1.loadRequest(Uri(host: 'google.com', scheme: 'https'));
    _controllerWeb2.setNavigationDelegate(NavigationDelegate(
      onPageFinished: (String url) {
        setState(() {
          _isWebReady = true;
        });
      }
    ));
    _controllerWeb2.loadRequest(Uri(host: 'dart.dev', scheme: 'https'));
    // _reload();
  }

  void _reload() {
    setState(() {
      _controllerWeb2.loadRequest(Uri(host: 'dart.dev', scheme: 'https'));
      _isWebReady = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        appBar: AppBar(
          title: Text('WebViews'),
        ),
        body: Column(
          children: <Widget>[
            Expanded(
              child: WebViewWidget(
                controller: _controllerWeb1,
              ),
            ),
            if (_isWebReady)
              Container(
                height: AdSize.mediumRectangle.height.toDouble(),
                width: AdSize.mediumRectangle.width.toDouble(),
                child: WebViewWidget(
                  controller: _controllerWeb2,
                ),
              )
            else
              SizedBox.shrink(),
            ElevatedButton(
              onPressed: _reload,
              child: Text('Reload'),
            ),
          ],
        ),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

https://github.com/flutter/flutter/assets/1921175/c5880e87-9156-4f90-ace9-30f08e863c7c

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[!] Flutter (Channel stable, 3.19.6, on macOS 14.5 23F79 darwin-arm64, locale en)
    • Flutter version 3.19.6 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (5 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update
      checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Platform android-34, build-tools 33.0.2
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version unknown)
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.17-11446219)

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio with Blaze.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 13 (API 33) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 125.0.6422.76

[✓] Network resources
    • All expected network resources are available.
```

</details>