Skip to content

Replace the new InputDecorator.error with errorBuilder or add TextFormField.validatorBuilder #135292

@TheLastFlame

Description

@TheLastFlame

Is there an existing issue for this?

Use case

InputDecorator.error added in #129275 is completely useless in its current form.

In fact, it is just a widget displayed under TextField, while blocking access to errorText, which completely breaks the existing validation mechanisms.
All interaction with this widget has to be done completely manually. If you put the TextField in Column, and our error widget under it, the effect will be exactly the same.

Because of this, closed #11068 is not actually resolved.

Proposal

#129275 is a fork of #118610, where this problem was discovered and discussion of possible solution methods began.

Four solutions to the problem were proposed in #118610 (comment), two of which were discarded.

Meanwhile, neither of the other two were implemented in #129275, for some reason approved for merging.

These options are:

Option 2
Add Widget error in InputDecoration
Add a validator variant: Widget? Function(String? input)? validatorBuilder in FormField. It allows to replace the classical validator with a version that can return a Widget instead of a string.

This option was liked by @justinmc but wasn't implemented in #129275

Option 4
Add Widget Function(String)? errorBuilder on InputDecoration which when not null is called to convert errorText to a Widget.

Both of these options solve the problem that has arisen.

I am willing to implement this, but I need approval and need to choose one of these options.

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: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.has partial patchThere is a PR awaiting someone to take it across the finish lineteam-text-inputOwned by Text Input team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions