Skip to content

When ReorderableListView's item has TextField, rebuild makes keyboard hide #62242

@wph144

Description

@wph144

I confirmed 25867 issue.
here is additional issue.

Steps to Reproduce

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
  title: 'Flutter Demo',
  theme: ThemeData(
    primarySwatch: Colors.blue,
  ),
  home: TestClass(),
));

class TestClass extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: FlatButton(
          child: Text('click me'),
          onPressed: () {
            Navigator.of(context)
              .push(MaterialPageRoute(builder: (context) => MyHomePage()));
          },
        ),
      ));
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController textEditingController;

  @override
  void initState() {
    textEditingController = TextEditingController();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('title here'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {});
        },
      ),
      body: ReorderableListView(
        children: <Widget>[
          Row(
            key: ValueKey('key'),
            children: <Widget>[
              Expanded(
                child: TextField(
                  controller: textEditingController,
                  decoration: InputDecoration(hintText: 'type in'),
                ),
              )
            ],
          )
        ],
        onReorder: (int oldIndex, int newIndex) {},
      ));
  }
}
  1. when keyboard is shown, click fab -> rebuild -> keyboard will be hidden
  2. if you replace 'ReorderableListView' with 'ListView', then keyboard is still shown. why are they different?
  3. we can avoid to rebuild some widgets using Provider. but now i cannot avoid rebuild on NestedScrollView + SliverPersistentHeader + ..etc or some other reason
Logs
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.4 19E287, locale ko-KR)
    • Flutter version 1.17.5 at /Users/wonpyohong/flutter
    • Framework revision 8af6b2f038 (3주 전), 2020-06-30 12:53:55 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

 
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/wonpyohong/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.2

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[!] Android Studio (version 3.4)
    • Android Studio at /Users/wonpyohong/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/183.5522156/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[!] IntelliJ IDEA Ultimate Edition (version 2020.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[✓] Connected device (2 available)
    • SM G950N          • ce0517155b10cc7a0d        • android-arm64 • Android 9 (API 28)
    • Wonpyo의 iPhone 11 • 00008030-000E0CCA36B9802E • ios           • iOS 13.5.1


Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsf: focusFocus traversal, gaining or losing focusf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.in triagePresently being triaged by the triage team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions