Repository: flutter
Issue: [Flutter Web] Rotating the keyboard from landscape to portrait with keyboard open leaves a white area
Labels: a: text input,platform-android,engine,platform-web,has reproducible steps,P2,team-web,triaged-web,found in release: 3.27,found in release: 3.28

### Steps to reproduce

I'm developing a web app with Flutter (version 3.27.0 but had same issue with 3.24). I deployed the app on a web server with flutter build web --release (thus should use canvaskit).

Using the web app on a Android (Samsung) device on multiple browsers (Chrome, Firefox and the default Samsung one) I noticed that whenever I rotate the screen from landscape to portrait with the keyboard open I get that the screen space previously used by the keyboard inset turns white and becomes unavailable for the app in a similar way to resizing the screen. Then, the app runs as expected in the remaining part of the screen. When I rotate the screen again, the full screen is used again by the web app.

The same issue happens whenever LastPass is automatically opened while writing the username or password (in this case even just staying in portrait). However, I prefer to focus on the rotation part as it is more reproducable.

On iOS the issue IS NOT present, probably due to the different rendering engine.
This problem happens on any screen which allows to open up the virtual keyboard.

### Expected results

When running on Flutter Web on android device (any browser), the app should properly reclaim its space after the keyboard is closed.

### Actual results

A white space area occupies the area previously used by the virtual keyboard inset when the app is rotated from landscape to portrait with the virtual keyboard open.

### Code sample

<details open><summary>Code sample</summary>

To verify that the issue is not related to my code I implemented the following basic app  with only a Scaffold and a TextFormField, which also presents the aforementioned problem once deployed. 

``` dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Window Bug Test',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple)
            .copyWith(surface: Colors.black),
        useMaterial3: true,
      ),
      home: const TestScreen(),
    );
  }
}

class TestScreen extends StatefulWidget {
  const TestScreen({super.key});

  @override
  State<TestScreen> createState() => _TestScreenState();
}

class _TestScreenState extends State<TestScreen> {
  final TextEditingController _controller = TextEditingController();

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: false,
        body: Center(
            child: Container(
          margin: const EdgeInsets.all(16),
          padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
          decoration: BoxDecoration(
              color: Colors.white, borderRadius: BorderRadius.circular(16)),
          child: TextFormField(
            controller: _controller,
            autocorrect: false,
            enableSuggestions: true,
            keyboardType: TextInputType.text,
            maxLines: 8,
            onSaved: (value) {},
            decoration: InputDecoration(
              hintText: "Add text here",
              hintStyle: Theme.of(context).textTheme.bodyMedium,
              alignLabelWithHint: true,
              border: InputBorder.none,
            ),
            style: Theme.of(context).textTheme.bodyMedium,
            autovalidateMode: AutovalidateMode.onUserInteraction,
            validator: (value) {
              if (value!.isEmpty || value.length < 16) {
                return "Input is too short";
              }
              return null;
            },
          ),
        )));
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

Screen looks normal
<img src="https://github.com/user-attachments/assets/fc7a1042-5230-4f98-ad20-cdf2f270233a" width ="300"> 

Rotate the screen and open the virtual keyboard

<img src="https://github.com/user-attachments/assets/f1287144-d27f-47f9-9b50-01ece7918ddd" width ="300">  

Rotate the screen back to portrait -> white area appears. Only goes away when rotating again

<img src="https://github.com/user-attachments/assets/e348a6b9-00cd-4136-8236-f9af307ee073" width ="300"> 


</details>


### Logs

<details open><summary>Logs</summary>

I could not see logs on the deployed application, but I don't get any error uploaded on Sentry.

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.27.0, on macOS 15.1.1 24B91 darwin-arm64, locale en-IT)
    • Flutter version 3.27.0 on channel stable at /Users/stefanoconoci/Code/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (8 days ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/stefanoconoci/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    ! iOS 18.2 Simulator not installed; this may be necessary for iOS and macOS development.
      To download and install the platform, open Xcode, select Xcode > Settings > Components,
      and click the GET button for the required platform.

      For more information, please visit:
        https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.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.10+0-17.0.10b1087.21-11609105)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • 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

[✓] VS Code (version 1.96.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.1.1 24B91 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.1.1 24B91 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 131.0.6778.140

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.```

</details>