Skip to content

Autocomplete doesn't open the dropdown when a value is selected #177429

Closed

Description

@ValentinVignal

Steps to reproduce

  1. Run flutter run on the code sample provided
  2. Enter a text (Ex: a) in the field without selecting an option.
  3. Focus and unfocus the field -> The dropdown shows and hides
  4. Select an option
  5. Focus and unfocus the field -> The dropdown doesn't show
  6. Edit the text
  7. Focus and unfocus the field -> The dropdown doesn't show

Expected results

I'd expect the dropdown to show even when a value is selected

Actual results

The dropdown doesn't show when a value is selected

It seems to come from

bool get _canShowOptionsView => _focusNode.hasFocus && _selection == null && _options.isNotEmpty;

Code sample

Code sample

You also can checkout https://github.com/ValentinVignal/flutter_app_stable/tree/flutter/autocomplete/cannot-open-dropdown-when-value-is-selected

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(home: Scaffold(body: Center(child: MyWidget())));
  }
}

class MyWidget extends StatefulWidget {
  const MyWidget({super.key});

  @override
  State<MyWidget> createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  static const _options = ['apple', 'banana', 'cherry', 'date', 'elderberry'];

  String? _selected;

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      spacing: 4,
      children: [
        Text('Selected: ${_selected ?? "none"}'),
        Autocomplete<String>(
          initialValue: TextEditingValue(text: _selected ?? ''),
          optionsBuilder: (TextEditingValue textEditingValue) {
            if (textEditingValue.text == '') {
              return const Iterable<String>.empty();
            }
            return _options.where((String option) {
              return option.contains(textEditingValue.text.toLowerCase());
            });
          },
          onSelected: (String selection) {
            setState(() {
              _selected = selection;
            });
          },
        ),
      ],
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2025-10-23.at.11.14.39.AM.mov

Logs

Logs
flutter run -d macos     
Resolving dependencies... 
Downloading packages... 
  characters 1.4.0 (1.4.1 available)
  flutter_lints 5.0.0 (6.0.0 available)
  lints 5.1.1 (6.0.0 available)
  material_color_utilities 0.11.1 (0.13.0 available)
  meta 1.16.0 (1.17.0 available)
  test_api 0.7.6 (0.7.7 available)
  vm_service 15.0.0 (15.0.2 available)
Got dependencies!
7 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Launching lib/main.dart on macOS in debug mode...
Updating minimum macOS deployment target to 10.15.
Upgrading project.pbxproj
Building macOS application...                                           
✓ Built build/macos/Build/Products/Debug/flutter_app_stable.app
2025-10-23 11:05:49.879 flutter_app_stable[2834:16113] Running with merged UI and platform thread. Experimental.
Failed to foreground app; open returned 1
Syncing files to device macOS...                                    67ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on macOS is available at: http://127.0.0.1:49451/rtx8u5AUnmc=/
The Flutter DevTools debugger and profiler on macOS is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:49451/rtx8u5AUnmc=/

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.35.6, on macOS 15.4.1 24E263 darwin-x64, locale en-US) [1,834ms]
    • Flutter version 3.35.6 on channel stable at /Users/valentinvignal/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9f455d2486 (2 weeks ago), 2025-10-08 14:55:31 -0500
    • Engine revision d2913632a4
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [5.6s]
    • Android SDK at /Users/valentinvignal/Library/Android/sdk
    • Emulator version 35.2.10.0 (build_id 12414864) (CL:N/A)
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/valentinvignal/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915915-b509.11)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[!] Xcode - develop for iOS and macOS (Xcode 16.0) [4.8s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    ✗ Unable to get list of installed Simulator runtimes.
    ! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods

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

[✓] Android Studio (version 2024.2) [27ms]
    • 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 21.0.3+-79915915-b509.11)

[✓] VS Code (version 1.105.1) [22ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.120.0

[✓] Connected device (2 available) [6.8s]
    • macOS (desktop) • macos  • darwin-x64     • macOS 15.4.1 24E263 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 141.0.7390.122

[✓] Network resources [418ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Oct 24, 2025
  2. huycozy commented on Oct 24, 2025

    @huycozy
    Member

    I'm also able to reproduce the issue on Flutter master channel as well.

    Flutter version
    [!] Flutter (Channel master, 3.38.0-1.0.pre-224, on macOS 26.0 25A354 darwin-arm64, locale en-US) [1,803ms]
        • Flutter version 3.38.0-1.0.pre-224 on channel master at /Users/huym4/Documents/WORKING/SDK/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huym4/Documents/WORKING/SDK/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huym4/Documents/WORKING/SDK/flutter_master. Consider adding /Users/huym4/Documents/WORKING/SDK/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huym4/Documents/WORKING/SDK/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huym4/Documents/WORKING/SDK/flutter_master. Consider adding /Users/huym4/Documents/WORKING/SDK/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 2b20cfe3f5 (59 minutes ago), 2025-10-23 22:19:42 -0400
        • Engine revision 2b20cfe3f5
        • Dart version 3.11.0 (build 3.11.0-55.0.dev)
        • DevTools version 2.51.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
  3. added
    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
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 24, 2025
  4. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Oct 29, 2025
  5. victorsanni commented on Oct 30, 2025

    @victorsanni
    Contributor

    I'm looking at the behavior of the HTML datalist element (which RawAutocomplete was inspired from) and this issue seems valid.

  6. github-actions commented on Dec 3, 2025

    @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.

  7. locked as resolved and limited conversation to collaborators on Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesteam-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