Skip to content

[docs] InputDecoration.enabled should explain how it interacts with suffixIcon #167713

Closed

Description

@navaronbracke

Use case

If I have a TextField widget that uses a suffixIcon, but the text field has enabled: false, the suffixIcon is not interactable, even though it has an onPressed set.

Example:

TextField(
  enabled: false,
  decoration: InputDecoration(
    suffixIcon: IconButton(
        onPressed: () {
           print('pressed');
        },
        icon: Icon(Icons.edit_outlined, size: 20, color: Colors.blue),
    )
  ),
)

I tried setting the enabled state of the InputDecoration, but that didn't help.
Per the docs:

If false helperText, errorText, and counterText are not displayed, and the opacity of the remaining visual elements is reduced.

Related: flutter-form-builder-ecosystem/flutter_form_builder#442

Proposal

Let the suffix icon handle its enabled state separately from the text field's enabled state. Maybe by allowing it to read the enabled state separately from the InputDecoration, without looking at TextField.enabled ?

Activity

  1. navaronbracke commented on Apr 24, 2025

    @navaronbracke
    ContributorAuthor

    A valid workaround seems to be setting both readOnly and enableInteractiveSelection while keeping the text field enabled.
    Maybe we should just document this instead? The docs for TextField.enabled say the following:

    If non-null this property overrides the [decoration]'s [InputDecoration.enabled] property.
    

    but as mentioned in the OP, the InputDecoration.enabled docs do not mention the suffix icon.

  2. changed the title [-]Allow enabled suffix button when the text field is disabled[/-] [+][docs] InputDecoration.enabled should explain how it interacts with suffixIcon[/+] on Apr 24, 2025
  3. added
    in triagePresently being triaged by the triage team
    a: text inputEntering text in a text field or keyboard related problems
    c: new featureNothing broken; request for a new capability
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Apr 25, 2025
  4. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Apr 30, 2025
  5. justinmc commented on Apr 30, 2025

    @justinmc
    Contributor

    Documenting the workaround sounds good.

    Your goal is to create a disabled TextField with a suffixIcon that still responds to taps?

  6. navaronbracke commented on Apr 30, 2025

    @navaronbracke
    ContributorAuthor

    Exactly!

  7. thakaredipali commented on May 28, 2025

    @thakaredipali
    Contributor

    @navaronbracke If you want to use a suffixIcon with an onPressed action while the TextFormField is disabled, you can use the readOnly property instead. This way, the text field remains non-editable, but the suffixIcon stays interactive.

  8. navaronbracke commented on May 28, 2025

    @navaronbracke
    ContributorAuthor

    @thakaredipali I already mentioned that in this comment

  9. thakaredipali commented on May 28, 2025

    @thakaredipali
    Contributor

    @navaronbracke Yes, got it.
    Documenting these things will help others understand more easily.
    Thanks

  10. added a commit that references this issue on Jun 11, 2025
    e765ed4
  11. github-actions commented on Jun 25, 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.

  12. locked as resolved and limited conversation to collaborators on Jun 25, 2025
  13. added a commit that references this issue on Jul 21, 2025
    90d0be9
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 lista: text inputEntering text in a text field or keyboard related problemsc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.fyi-text-inputFor the attention of Text Input teamteam-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