Skip to content

Flutter layout not updated when Large iOS custom keyboard is dismissed. #99951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
coldstar96 opened this issue Mar 11, 2022 · 10 comments
Closed
Labels
a: text input Entering text in a text field or keyboard related problems c: rendering UI glitches reported at the engine/skia or impeller rendering level engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version

Comments

@coldstar96
Copy link

coldstar96 commented Mar 11, 2022

Steps to Reproduce

Keyboard dismiss is not handled properly for iOS custom keyboards. If you look at second video, it seems like the issue happens if the custom keyboard height is too large when dismissed.

Precondition: Download custom keyboards: Bitmoji, Slyder

  1. Copy paste main.dart to new project
  2. Follow steps
custom_keyboard_layout_issue.MP4
RPReplay_Final1646969495.MP4

Expected results: Lays out widgets properly when keyboard is dismissed

Actual results: It doesn't listen to keyboard dismiss when custom keyboard is too large.

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Container(
        color: Colors.blue.shade100,
        child: Column(
          children: [
            const SizedBox(height: 48),
            const Padding(
              padding: EdgeInsets.symmetric(horizontal: 16),
              child: Text(
                '1. Change iOS keyboard to Bitmoji or Slyder keyboard.\n'
                '2. Tap on the button below.\n'
                '3. Navigate back to previous route.\n'
                '4. Check that shaded blue(Scaffold.body) not covering entire screen.\n'
                '5. Compare the behavior with OS keyboard',
                style: TextStyle(fontSize: 20),
              ),
            ),
            const TextField(autofocus: true),
            const Spacer(),
            ElevatedButton(
              onPressed: () {
                FocusScope.of(context).unfocus();
                Navigator.of(context).push(CupertinoPageRoute(
                  builder: (context) {
                    return const MyHomePage(title: 'Another Page');
                  },
                ));
              },
              child: const Text('Hello', style: TextStyle(fontSize: 30)),
            )
          ],
        ),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: [Icons.abc, Icons.train]
            .map((e) => BottomNavigationBarItem(icon: Icon(e), label: 'hi'))
            .toList(),
      ),
    );
  }
}
Logs
@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label Mar 11, 2022
@danagbemava-nc
Copy link
Member

Hi @coldstar96, thanks for reporting this.

Please provide the output of flutter doctor -v.

Thank you

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 11, 2022
@coldstar96
Copy link
Author

coldstar96 commented Mar 11, 2022

flutter doctor -v
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.1 21C52 darwin-arm, locale en-US)
    • Flutter version 2.10.3 at /Users/c/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (9 days ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/c/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.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 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0

[✓] Connected device (2 available)
    • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64  • Android 11 (API 30) (emulator)
    • Chrome (web)              • chrome        • web-javascript • Google Chrome 99.0.4844.51
    ! Error: ABC X is not connected. Xcode will continue when ABC X is connected. (code -13)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 11, 2022
@danagbemava-nc
Copy link
Member

Hi @coldstar96, I'm attempting to reproduce but it doesn't seem to occur for me. Kindly check the video below and let me know if I'm missing something

RPReplay_Final1647239684.MP4

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 14, 2022
@coldstar96
Copy link
Author

coldstar96 commented Mar 18, 2022

hmm.. I'm not sure if there's additional environment requirements but it seems like @luckysmg was able to repro from flutter/engine#31982. If his change seems reasonable, would you be able to approve it?

If this helps, my device is iPhone 13 pro max, iOS 15.3.1

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 18, 2022
@luckysmg
Copy link
Contributor

luckysmg commented Mar 18, 2022

Yes, @coldstar96 @danagbemava-nc I can reproduce this issue.
My test device is iPhone13 Pro. iOS 15.4

Here is demo code. You can try to dismiss keyboard by tapping the blank area in scaffold.

Demo code
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: (){
        FocusScope.of(context).unfocus();
      },
      child: Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Container(
          color: Colors.blue.shade100,
          child: Column(
            children: [
              const SizedBox(height: 48),
              const Padding(
                padding: EdgeInsets.symmetric(horizontal: 16),
                child: Text(
                  '1. Change iOS keyboard to Bitmoji or Slyder keyboard.\n'
                      '2. Tap on the button below.\n'
                      '3. Navigate back to previous route.\n'
                      '4. Check that shaded blue(Scaffold.body) not covering entire screen.\n'
                      '5. Compare the behavior with OS keyboard',
                  style: TextStyle(fontSize: 20),
                ),
              ),
              const TextField(autofocus: true),
              const Spacer(),
              ElevatedButton(
                onPressed: () {
                  FocusScope.of(context).unfocus();
                  Navigator.of(context).push(CupertinoPageRoute(
                    builder: (context) {
                      return const MyHomePage(title: 'Another Page');
                    },
                  ));
                },
                child: const Text('Hello', style: TextStyle(fontSize: 30)),
              )
            ],
          ),
        ),
        bottomNavigationBar: BottomNavigationBar(
          items: [Icons.abc, Icons.train]
              .map((e) => BottomNavigationBarItem(icon: Icon(e), label: 'hi'))
              .toList(),
        ),
      ),
    );
  }
}

@danagbemava-nc
Copy link
Member

Hmm, you both appear to be using a variation of iPhone 13, perhaps this only affects newer iphones?
I tested on an iPhone XS with the sample provided by @luckysmg and I still was unable to reproduce it.

video
RPReplay_Final1647585818.MP4

If his change seems reasonable, would you be able to approve it?

The reviewers will make that decision.

Labeling this for further investigation as I cannot reproduce this locally.

@danagbemava-nc danagbemava-nc added a: text input Entering text in a text field or keyboard related problems platform-ios iOS applications specifically engine flutter/engine repository. See also e: labels. c: rendering UI glitches reported at the engine/skia or impeller rendering level and removed in triage Presently being triaged by the triage team labels Mar 18, 2022
@chinmaygarde chinmaygarde added the P2 Important issues not at the top of the work list label Mar 21, 2022
@chinmaygarde
Copy link
Member

cc @LongCatIsLooong

@luckysmg
Copy link
Contributor

luckysmg commented Apr 1, 2022

Fixed by flutter/engine#31982

@danagbemava-nc
Copy link
Member

@luckysmg thanks for your contribution.

@danagbemava-nc danagbemava-nc added r: fixed Issue is closed as already fixed in a newer version and removed waiting for PR to land (fixed) A fix is in flight labels Apr 1, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems c: rendering UI glitches reported at the engine/skia or impeller rendering level engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
Development

No branches or pull requests

5 participants