Skip to content

[AutoComplete] Once an option has been selected (including using Enter), it can no longer be selected again (Regression) #182927

@irayshi

Description

@irayshi

Steps to reproduce

Enter text into the AutoComplete field.
Select one of the suggested items.
Press Enter to trigger textEditingController.clear().
Select the same item again from the suggestions.
Press Enter.

Expected results

After selecting an item and clearing the field with textEditingController.clear(), selecting the same item again should still work.

Actual results

After selecting an item, clearing the field with textEditingController.clear(), and selecting the same item again, it no longer works.

Code sample

import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'testing', home: ErrorAutocomplete());
  }
}

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

  @override
  State<ErrorAutocomplete> createState() => _ErrorAutocompleteState();
}

class _ErrorAutocompleteState extends State<ErrorAutocomplete> {
  final textCtrl = TextEditingController();
  final textFocus = FocusNode();
  final listItem = <String>['test', 'abc', 'dexter'];

  @override
  void dispose() {
    textCtrl.dispose();
    textFocus.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('testing')),
      body: Row(
        spacing: 10,
        children: [
          Expanded(
            child: Autocomplete(
              textEditingController: textCtrl,
              focusNode: textFocus,
              optionsBuilder: (textEditingValue) {
                return listItem.where(
                  (e) => e.toLowerCase().contains(
                    textEditingValue.text.toLowerCase(),
                  ),
                );
              },
            ),
          ),
          IconButton(
            onPressed: () {
              textCtrl.clear();
            },
            icon: Icon(Icons.add),
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screencast.dari.2026-02-26.10-23-11.webm
Screenshots / Video demonstration

[Upload media here]

Flutter Doctor output

[✓] Flutter (Channel stable, 3.41.1, on Ubuntu 24.04.4 LTS 6.17.0-14-generic, locale id_ID.UTF-8) [162ms]
• Flutter version 3.41.1 on channel stable at /usr/bin/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 582a0e7 (13 hari yang lalu), 2026-02-12 17:12:32 -0800
• Engine revision 3452d73
• Dart version 3.11.0
• DevTools version 2.54.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android,
enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging,
enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [7,5s]
• Android SDK at /home/unknown/Android/Sdk
• Emulator version 35.5.10.0 (build_id 13402964) (CL:N/A)
• Platform android-36, build-tools 35.0.0
• Java binary at: /opt/android-studio/jbr/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 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.

[✓] Chrome - develop for the web [57ms]
• Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop [2,1s]
• Ubuntu clang version 18.1.3 (1ubuntu1)
• cmake version 3.28.3
• ninja version 1.11.1
• pkg-config version 1.8.1
• OpenGL core renderer: Mesa Intel(R) HD Graphics 4400 (HSW GT2)
• OpenGL core version: 4.6 (Core Profile) Mesa 25.2.8-0ubuntu0.24.04.1
• OpenGL core shading language version: 4.60
• OpenGL ES renderer: Mesa Intel(R) HD Graphics 4400 (HSW GT2)
• OpenGL ES version: OpenGL ES 3.2 Mesa 25.2.8-0ubuntu0.24.04.1
• OpenGL ES shading language version: OpenGL ES GLSL ES 3.20
• GL_EXT_framebuffer_blit: yes
• GL_EXT_texture_format_BGRA8888: yes

[✓] Connected device (2 available) [519ms]
• Linux (desktop) • linux • linux-x64 • Ubuntu 24.04.4 LTS 6.17.0-14-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 145.0.7632.109

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.frameworkflutter/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 teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions