Skip to content

Dropdown list incorrect position when on-screen keyboard closes #46676

@roxifas

Description

@roxifas

Steps to Reproduce

  1. Open dialog with a text field and a dropdown button.
  2. Focus the text field by tapping on it, this opens the keyboard and changes the position of the dialog.
  3. Tap on the dropdown button, its' list is opened in correct position, but the keyboard closes making the dialog go downwards while the dropdown list stays where it opened.

This could also be reproduced without a dialog, but in some form which scrolls, but the behaviour is much more visible with a dialog.

Screenshot of this behaviour:
image

Code sample:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => showDialog(
          context: context,
          builder: (context) => MyDialog(),
        ),
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

class MyDialog extends StatelessWidget {
  @override
  Widget build(BuildContext context) => AlertDialog(
        content: Row(
          children: <Widget>[
            Expanded(
              child: TextField(),
            ),
            Expanded(
              child: DropdownButton<String>(
                items: ['1', '2', '3']
                    .map((i) => DropdownMenuItem<String>(
                          value: i,
                          child: Text(i),
                        ))
                    .toList(),
                onChanged: (_) {},
              ),
            ),
          ],
        ),
      );
}

Target Platform: Android
Target OS version/browser: tested with Android 9 and 8
Devices: tested with Android 9 emulator, Lenovo Tab M10 (Android 8)

Logs

[√] Flutter (Channel beta, v1.12.13+hotfix.4, on Microsoft Windows [Version 10.0.18362.476], locale lt-LT)
    • Flutter version 1.12.13+hotfix.4 at C:\Users\Rokas\FlutterSDK\flutter
    • Framework revision fb60324e6f (11 hours ago), 2019-12-09 15:58:15 -0800
    • Engine revision ac9391978e
    • Dart version 2.7.0


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\Rokas\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 42.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.40.2)
    • VS Code at C:\Users\Rokas\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.6.0

[√] Connected device (1 available)
    • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: renderingUI glitches reported at the engine/skia or impeller rendering levelf: material designflutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions