Skip to content

[Android Web] resizeToAvoidBottomInset broken on Android. Keyboard breaks layout. #175074

@MichealReed

Description

@MichealReed

Steps to reproduce

  1. Build an app for android with text input and deploy to web.

Expected results

  1. The keyboard should open and close, with the layout either adapting if resizeToAvoidBottomInset is true or no layout adaptation if resizeToAvoidBottomInset is false.
  2. Open and close the keyboard at https://android-keyboard-insets.web.app/ a few times to see the effect.

Actual results

The behavior is the same regardless of resizeToAvoidBottomInset and the keyboard creates severe layout issues.

Code sample

Code sample
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const KeyboardTestApp());
}

class KeyboardTestApp extends StatelessWidget {
  const KeyboardTestApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Android Web Keyboard Test',
      theme: ThemeData.dark(),
      home: const TestPage(),
    );
  }
}

class TestPage extends StatefulWidget {
  const TestPage({super.key});

  @override
  State<TestPage> createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  final _controller1 = TextEditingController();
  final _controller2 = TextEditingController();
  final _controller3 = TextEditingController();

  bool get isAndroidWeb =>
      kIsWeb && defaultTargetPlatform == TargetPlatform.android;

  @override
  void dispose() {
    _controller1.dispose();
    _controller2.dispose();
    _controller3.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFF0A1A32),
      resizeToAvoidBottomInset: !isAndroidWeb,
      body: Container(
        decoration: const BoxDecoration(
          gradient: RadialGradient(
            colors: [Color(0xFF172033), Color(0xFF0A1A32)],
            radius: 1.2,
            center: Alignment(-0.6, -0.8),
          ),
        ),
        child: SafeArea(
          child: Center(
            child: SingleChildScrollView(
              padding: EdgeInsets.only(
                left: 24,
                right: 24,
                top: 24,
                bottom: isAndroidWeb
                    ? MediaQuery.of(context).viewInsets.bottom + 24
                    : 24,
              ),
              child: ConstrainedBox(
                constraints: const BoxConstraints(maxWidth: 400),
                child: Card(
                  elevation: 8,
                  color: Colors.white.withOpacity(0.1),
                  child: Padding(
                    padding: const EdgeInsets.all(24),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        const Icon(
                          Icons.bug_report,
                          size: 48,
                          color: Colors.blue,
                        ),
                        const SizedBox(height: 16),
                        const Text(
                          'Keyboard Test',
                          style: TextStyle(
                            fontSize: 24,
                            fontWeight: FontWeight.bold,
                            color: Colors.white,
                          ),
                        ),
                        const SizedBox(height: 8),
                        Text(
                          'Platform: ${kIsWeb ? 'Web' : 'Native'} - ${defaultTargetPlatform.name}',
                          style: const TextStyle(color: Colors.grey),
                        ),
                        const SizedBox(height: 24),

                        TextField(
                          controller: _controller1,
                          decoration: const InputDecoration(
                            labelText: 'Field 1',
                            border: OutlineInputBorder(),
                          ),
                        ),
                        const SizedBox(height: 16),

                        TextField(
                          controller: _controller2,
                          decoration: const InputDecoration(
                            labelText: 'Field 2',
                            border: OutlineInputBorder(),
                          ),
                        ),
                        const SizedBox(height: 16),

                        TextField(
                          controller: _controller3,
                          decoration: const InputDecoration(
                            labelText: 'Field 3',
                            border: OutlineInputBorder(),
                          ),
                        ),
                        const SizedBox(height: 24),

                        SizedBox(
                          width: double.infinity,
                          child: ElevatedButton(
                            onPressed: () {
                              ScaffoldMessenger.of(context).showSnackBar(
                                const SnackBar(
                                  content: Text('Button pressed!'),
                                ),
                              );
                            },
                            child: const Text('Test Button'),
                          ),
                        ),

                        const SizedBox(height: 16),
                        Text(
                          'Android Web Fix: ${isAndroidWeb ? 'Applied' : 'Not needed'}',
                          style: TextStyle(
                            color: isAndroidWeb ? Colors.green : Colors.grey,
                            fontSize: 12,
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration Image

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.33.0-1.0.pre-1246, on Microsoft Windows [Version 10.0.26100.4946], locale en-US) [1,370ms]
    • Flutter version 3.33.0-1.0.pre-1246 on channel master at D:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cc4f1a09f1 (5 weeks ago), 2025-08-02 01:10:10 -0400
    • Engine revision cc4f1a09f1
    • Dart version 3.10.0 (build 3.10.0-59.0.dev)
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets

[✓] Windows Version (11 Pro 64-bit, 24H2, 2009) [3.7s]

[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0-rc5) [1,147ms]
    • Android SDK at C:\Users\x\AppData\Local\Android\Sdk
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 36.0.0-rc5
    • ANDROID_HOME = C:\Users\x\AppData\Local\Android\Sdk
    • Java binary at: C:\Users\x\.jdks\corretto-19.0.2\bin\java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Corretto-19.0.2.7.1 (build 19.0.2+7-FR)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Chrome - develop for the web [56ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4) [55ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.12.35707.178
    • Windows 10 SDK version 10.0.22621.0

[✓] Connected device (3 available) [114ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.4946]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 140.0.7339.80
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 140.0.3485.54

[✓] Network resources [464ms]
    • All expected network resources are available.

Also tried with channel stable and reproduced this with an older app published so this issue has been around on android web for a significant period of time. The bug happens both with firefox and chrome.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: text inputEntering text in a text field or keyboard related problemsbrowser: chrome-androidonly manifests in Chrome on Androidc: regressionIt was better in the past than it is nowcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.f: focusFocus traversal, gaining or losing focusf: material designflutter/packages/flutter/material repository.found in release: 3.37Found to occur in 3.37frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions