Skip to content
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

When open keyboard, automatically closed #37

Open
juanlabrador opened this issue Sep 8, 2020 · 24 comments
Open

When open keyboard, automatically closed #37

juanlabrador opened this issue Sep 8, 2020 · 24 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@juanlabrador
Copy link

I receive in console

W/IInputConnectionWrapper(14786): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(14786): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(14786): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper(14786): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper(14786): endBatchEdit on inactive InputConnection

The keyboard not stay open when open, any idea? If disable o remove the listen, the keyboard stay open.

@MisterJimson
Copy link
Owner

Wow thats interesting. Can you share any code snipped you have, confirm the version of the package, and the device you are using?

@juanlabrador
Copy link
Author

[✓] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.6 19G2021, locale es-419)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2020.2.1)
[!] VS Code (version 1.48.0)
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)

@juanlabrador
Copy link
Author

The device is a Mi A2 with Android One, Android 10., Is when click on TextFormField, or TextField

@juanlabrador
Copy link
Author

video-to-gif-converter

@juanlabrador
Copy link
Author

I use this lib for when keyboard is open, I hide widgets, for the content adjust to write more confortable, when keyboard is hide, I show widgets again

@juanlabrador
Copy link
Author

Then the method listen, return true when open and immediately false and It close, Thanks.

@MisterJimson
Copy link
Owner

May be related: flutter/flutter#9471

@tmthecoder
Copy link

tmthecoder commented Sep 10, 2020

I am having this same problem as well, but it didn't seem to persist on iOS, only Android.

@MisterJimson MisterJimson added the bug Something isn't working label Sep 14, 2020
@MisterJimson
Copy link
Owner

I would love a reproducible sample to help work on this.

@MisterJimson MisterJimson added the help wanted Extra attention is needed label Dec 5, 2020
@ajaygautam
Copy link

ajaygautam commented Dec 23, 2020

I am facing this issue too - on iOS. Have not tried on Android.
Keyboard shows up, then disappears VERY quick. Have not been able to track whats causing this.

@MisterJimson here is this issue reproduced: https://github.com/ajaygautam/flutter_repro_keyboard_dismiss_issue

Relevant details have been added to the readme in the repo. I have added you as a collaborator to the repo. Please do feel free to commit changes.

Primary code segments:

class RouteWithKeyboardVisibilityBuilder extends StatelessWidget {
  final String title;

  const RouteWithKeyboardVisibilityBuilder({Key key, this.title = "RouteWithKeyboardVisibilityBuilder"})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return KeyboardVisibilityBuilder(builder: (context, isKeyboardVisible) {
      print("=-=-=-=-=-= Building with keyboard visibility set to: --||$isKeyboardVisible||-- for screen with title $title =-=-=-=-=-=");
      return Material(
          child: Container(
              color: Colors.blue[200],
              child: Center(
                  child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                    Text(title),
                    SizedBox(height: 16),
                    WidgetWithTextEdit(),
                    SizedBox(height: 16),
                    BackNextButtonRow()
                  ]))));
    });
  }
}

class WidgetWithTextEdit extends StatelessWidget {
  final Key key = UniqueKey();

  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;

    return SizedBox(
      height: screenSize.height * 0.1,
      width: screenSize.width * 0.67,
      child: new TextFormField(
        key: key,
        decoration: InputDecoration(hintText: "Tap to Enter Data"),
      ),
    );
  }
}

Would appreciate any help / info. Let me know if you want me to try anything.

@ajaygautam
Copy link

I am having this same problem as well, but it didn't seem to persist on iOS, only Android.

@tmthecoder were you able to resolve this?

@tmthecoder
Copy link

I am having this same problem as well, but it didn't seem to persist on iOS, only Android.

@tmthecoder were you able to resolve this?

Not yet, I'm still awaiting a resolution

@ajaygautam
Copy link

So... looks like package keyboard_visibility does not cause this behavior - atleast in the test app at: https://github.com/ajaygautam/flutter_repro_keyboard_dismiss_issue

I have updated the app to support both keyboard_visibility and flutter_keyboard_visibility.
In main.dart, look for switchToKeyboardVisibility... is set true... the app will use keyboard_visibility package. If false, the app will use flutter_keyboard_visibility.

Going to try this with my actual app now.

Thanks

@MisterJimson
Copy link
Owner

@ajaygautam can you provide steps to reproduce the issue with your example repo? I am running it and have tried switching switchToKeyboardVisibility false.

I am not seeing any issues. I can clock next and tap in the text field and the keyboard shows correctly.

@ajaygautam
Copy link

That is strange! It seems to be working fine now.
Well... I guess its ok to close this...

FWIW... flutter doctor output:

[✓] Flutter (Channel beta, 1.25.0-8.1.pre, on macOS 11.1 20C69 darwin-arm, locale en-US)
    • Flutter version 1.25.0-8.1.pre at /Users/agautam/tools/flutter
    • Framework revision 8f89f6505b (3 weeks ago), 2020-12-15 15:07:52 -0800
    • Engine revision 92ae191c17
    • Dart version 2.12.0 (build 2.12.0-133.2.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/agautam/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • 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-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.0

[✓] Android Studio
    • Android Studio at /Applications/Android Studio 4.2 Preview.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.8+10-b944.6842174)

[✓] Android Studio (version 4.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 1.8.0_242-release-1644-b3-6915495)

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

[✓] Connected device (1 available)
    • iPhone (mobile) • 92cc6d36662ed70bd2442ee0aac0decfa2e34e24 • ios • iOS 14.1

• No issues found!

@MisterJimson
Copy link
Owner

Ok. I am going to leave it open as there is still and issue with Android it seems from the other people in this thread.

@MisterJimson
Copy link
Owner

4.0.4-beta.0 is available with a new Android implementation using the fairly new WindowInsetsCompat features.

Any feedback is appreciated before I merge this into a main version. I suspect it may help resolve this issue.

@MisterJimson
Copy link
Owner

Should be closed in 4.0.4, but I had trouble reproducing. Feel free to reopen with more info.

@haliknihudas666
Copy link

haliknihudas666 commented May 5, 2021

Before the flutter 2.0 update arrive this code is working fine but after the flutter 2.0 update and this package update to support null safety, the keyboard now closes when transitioning to a new layout that has 3 columns from only 2 columns

keyboard.mp4

this is the code I used to replicate the problem: https://github.com/haliknihudas666/flutter_keyboardVisibility_demo

please reopen this issue

@MisterJimson MisterJimson reopened this May 5, 2021
@BrunoC96
Copy link

BrunoC96 commented Aug 1, 2021

I have the same issue today (on Android), and i resolve by changing from Stateless Widget to Statefull Widget the Form where the TextInput have the problem

@Kishan-Somaiya
Copy link

Thanks @BrunoC96 for the help, it worked 🎉. But dont know why this behavior for the Stateless widget.

@xetra11
Copy link

xetra11 commented Dec 13, 2022

Unfortunately does not work for me. Tried all workaround until this message.

[✓] Flutter (Channel stable, 3.3.9, on macOS 12.3.1 21E258 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.4)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

@maxstubbersfield
Copy link

Hi there, I had the same issue and I was able to fix it by creating a GlobalKey<FormState> and using that key with the TextField.

This StackOverflow post has the details: https://stackoverflow.com/questions/51320692/flutter-keyboard-disappears-immediately-when-editing-my-text-fields

@tudor07
Copy link

tudor07 commented Aug 14, 2023

I have the exact same problem. When keyboard is shown I remove a big widget from the widget tree, that causes the keyboard to be dismissed.

Edit: I found an workaround. If I add a GlobalKey to my TextField the keyboard no longer dismisses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants