Skip to content

TextFields (and TextFormFields) should allow displaying error state without error text #54104

Open

Description

@rami-a

Use case

There are occasions where multiple TextField (or more likely TextFormField) are used on a page and the UX could call for a custom error solution instead of each textfield displaying an error message. We want to maintain the validate logic that exists on the Form but allow the developer to decide whether each textfield should show its error text.

Proposal

Adding a new parameter to InputDecoration that tells TextFields they should not display their error text but still display any other error specific content (errorBorder, etc)

This would have to also work with the validate logic of TextFormField as well so that if a form is validated the error text can choose to not be displayed on each text field.

cc @justinmc
Similar to #52634

Activity

  1. mikuhl-dev commented on Apr 6, 2020

    @mikuhl-dev

    This is something I do too! Right now this is how I do it:

    decoration: InputDecoration(
      counterStyle: const TextStyle(height: 0),
      counterText: ' ',
      errorStyle: const TextStyle(height: 0),
    ),

    And then error for the validator is simply an empty string. So when there is an error all that is shown is the red error line.

  2. rami-a commented on Apr 6, 2020

    @rami-a
    ContributorAuthor

    yup I'm using this workaround for now as well but it would be nice to have a more formal way to support this.

  3. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Apr 6, 2020
  4. added
    a: text inputEntering text in a text field or keyboard related problems
    on Jun 18, 2020
  5. roti commented on Mar 21, 2021

    @roti

    The workaround from @MichaelPriebe has a problem: it causes an empty space to appear under the textfield (where the error used to be). I would be nice to have a solution without this space.

  6. talski commented on Aug 6, 2021

    @talski

    The workaround from @MichaelPriebe has a problem: it causes an empty space to appear under the textfield (where the error used to be). I would be nice to have a solution without this space.

    Try this: TextStyle(height: 0.01), I get it working here with master.

  7. aytunch commented on Dec 17, 2021

    @aytunch

    The workaround from @MichaelPriebe has a problem: it causes an empty space to appear under the textfield (where the error used to be). I would be nice to have a solution without this space.

    Try this: TextStyle(height: 0.01), I get it working here with master.

    Thank you this worked by using 0.001 however this is a very ugly solution.
    We need a real solution to lose error text and prevent text field outline getting shorter height.
    It is crazy such a simple thing is not still solved.

  8. Lorenzohidalgo commented on Feb 9, 2022

    @Lorenzohidalgo

    Thanks! using TextStyle(height: 0.001) worked to hide the error message.

    It would be nice to be able to decide how to show the error message from the different options:

    • not showing this at all
    • showing it under the textform
    • showing the error text as tooltip.
  9. boganiLuca commented on Feb 2, 2023

    @boganiLuca

    Similar problem here on web platform:
    immagine
    The TextFormField on the left is using the "0.01" workaround, and the one on the right is using the TextStyle(height: 0) solution (which I'm pretty sure it worked fine some time ago, as I used it in another project of mine)

  10. jbryanh commented on Aug 27, 2023

    @jbryanh

    In conjunction with this, an errorLabelTextStyle property seems reasonable.

  11. flutter-triage-bot commented on Oct 23, 2023

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-design label.

  12. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Feb 29, 2024
  13. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
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 Flutterp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-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