Skip to content

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

@ValentinVignal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.found 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 onteam-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