Skip to content

SearchBar fails to show keyboard on Android after coming back from the background #134965

Closed

Description

@AndreHaueisen

Is there an existing issue for this?

Steps to reproduce

  1. Click the SearchBar. They keyboard will come up
  2. Send the app to the background
  3. Come back from the background
  4. Click the SearchBar. The keyboard will not show

Extra info:
I tested on two Android devices. On my Pixel 2 running Android 11 everything worked fine. The problem happened on my Pixel 6 running Android 13

Expected results

When I come back from the background, I expect to see the keyboard again, or at least that it shows again if I click the SearchBar.

Actual results

I can't call the keyboard back

Code sample

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const Scaffold(
        body: Center(child: SearchBar()),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

https://drive.google.com/file/d/14rhlifS67w9rBBkJvMrqFUFonAoB8vOa/view?usp=sharing

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.4, on macOS 13.5.2 22G91 darwin-arm64
    (Rosetta), locale en-BR)
[!] Android toolchain - develop for Android devices (Android SDK version
    33.0.0-rc1)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Community Edition (version 2023.2.2)
[✓] VS Code (version 1.80.1)
[✓] Connected device (4 available)
[✓] Network resources

Activity

  1. danagbemava-nc commented on Sep 19, 2023

    @danagbemava-nc
    Member

    Hi @AndreHaueisen, I'm curious, do you only experience this when you use the gesture-based navigation in android?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 19, 2023
  3. AndreHaueisen commented on Sep 19, 2023

    @AndreHaueisen
    Author

    Hey, @danagbemava-nc. No, it also happens when the 3-button navigation is active

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 19, 2023
  5. huycozy commented on Sep 20, 2023

    @huycozy
    Member

    @AndreHaueisen I checked this on my two devices (Realme 6 Android 11 and Pixel 4 Android 13) but can't reproduce the issue.
    Can you re-check this with a simple TextField widget? Please also confirm if the issue is reproducible on a newly created Flutter project or only on the current project.

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 20, 2023
  7. AndreHaueisen commented on Sep 20, 2023

    @AndreHaueisen
    Author

    @huycozy The problem is specific to SearchBar. TextField works as expected.
    I created a new project and tested it again. Same problem.

  8. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 20, 2023
  9. danagbemava-nc commented on Sep 21, 2023

    @danagbemava-nc
    Member

    Thanks for the info @AndreHaueisen. Initially, I could not reproduce when I used the 3-button navigation. I tried again today and it could reproduce, however, in my case, this was not consistent. So far, this only reproduced on android for me.

    screen-20230921-070610.mp4
    complete sample
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
            useMaterial3: true,
          ),
          home: const Scaffold(
            body: Center(child: SearchBar()),
          ),
        );
      }
    }
    flutter doctor -v
    [!] Flutter (Channel stable, 3.13.5, on macOS 13.5.2 22G91 darwin-arm64, locale en-GB)
        • Flutter version 3.13.5 on channel stable at /Users/nexus/dev/sdks/flutter
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 12fccda598 (34 hours ago), 2023-09-19 13:56:11 -0700
        • Engine revision bd986c5ed2
        • Dart version 3.1.2
        • DevTools version 2.25.0
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.1
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0)
        • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
        • Build 15A240d
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Users/nexus/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 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 75.1.4
        • Dart plugin version 232.9559.10
    
    [✓] VS Code (version 1.82.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.72.0
    
    [✓] Connected device (5 available)
        • Pixel 7 (mobile)     • 28291FDH2001SA            • android-arm64  • Android 13 (API 33)
        • Nexus (mobile)       • 00008020-001875E83A38002E • ios            • iOS 17.0 21A329
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 17.0 21A329
        • macOS (desktop)      • macos                     • darwin-arm64   • macOS 13.5.2 22G91 darwin-arm64
        • Chrome (web)         • chrome                    • web-javascript • Google Chrome 117.0.5938.88
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel master, 3.14.0-14.0.pre.410, on macOS 13.5.2 22G91 darwin-arm64, locale en-GB)
        • Flutter version 3.14.0-14.0.pre.410 on channel master at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 07cc3f7a61 (74 minutes ago), 2023-09-21 07:54:19 +0200
        • Engine revision 3e66ffa6aa
        • Dart version 3.2.0 (build 3.2.0-185.0.dev)
        • DevTools version 2.28.0-dev.12
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.1
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0)
        • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
        • Build 15A240d
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Users/nexus/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 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 75.1.4
        • Dart plugin version 232.9559.10
    
    [✓] VS Code (version 1.82.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.72.0
    
    [✓] Connected device (5 available)
        • Pixel 7 (mobile)     • 28291FDH2001SA            • android-arm64  • Android 13 (API 33)
        • Nexus (mobile)       • 00008020-001875E83A38002E • ios            • iOS 17.0 21A329
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 17.0 21A329
        • macOS (desktop)      • macos                     • darwin-arm64   • macOS 13.5.2 22G91 darwin-arm64
        • Chrome (web)         • chrome                    • web-javascript • Google Chrome 117.0.5938.88
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
  10. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Sep 21, 2023
  11. 9 remaining items

  12. flutter-triage-bot commented on Sep 21, 2023

    @flutter-triage-bot

    The triaged-android label is irrelevant if there is no team-android label or fyi-android label.

  13. added
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    P2Important issues not at the top of the work list
    on Sep 21, 2023
  14. Renzo-Olivares commented on Nov 7, 2023

    @Renzo-Olivares
    Contributor

    I'm able to reproduce this on the master branch as well. I haven't been able to track down exactly why since it is a bit inconsistent but I think it has something to do with the fact that we activate the TextField by calling requestFocus on its FocusNode rather than interacting with the underlying TextField through TextSelectionGestureDetector. I'm not able to reproduce this issue on my PR that enables text selection in the search bar #137636 . I'll try to write a regression test to confirm this is fixed.

  15. Renzo-Olivares commented on Nov 10, 2023

    @Renzo-Olivares
    Contributor

    This was closed by #137636 which has landed on the master branch, if you are still experiencing this issue please feel free to re-open.

  16. added
    r: fixedIssue is closed as already fixed in a newer version
    on Nov 13, 2023
  17. github-actions commented on Nov 27, 2023

    @github-actions

    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.

  18. locked as resolved and limited conversation to collaborators on Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsfound in release: 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.fyi-frameworkFor the attention of Framework teamhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: 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