Skip to content

Rethink Forms #6097

@mpcomplete

Description

@mpcomplete

The Form/Input API is confusing. I think it needs a redesign.

In general, FormField provides a second, slightly easier way of doing things that Input does. This is nice to have but it also causes a lot of confusion. Ideally there's a way to combine FormField's ease of use with Input's flexibility.

Problems:

  • You can provide a formField, which causes the Input to manage the InputValue for you - but only when a descendant of a Form. This is a strange restriction that we should remove.
  • If you provide a formField, the value argument acts as an initial value, not the current value. Changes to value are ignored in future widget re-builds.
  • FormField's setter callback and Input's onChanged callback fight each other. We should have one or the other.
  • FormField's validator callback and Input's errorText argument fight each other. We should have one or the other.
  • Form's onSubmitted callback is not useful. It doesn't inform you which Input was submitted, and whole forms are generally not submitted when the "accept" key is tapped anyway.
  • It would be convenient if there was a way for the Form to tell you if any of the fields were invalid (e.g. to disable/enable the "Submit" button). [added by @Hixie]

At the very least, we should remove the Form ancestor. We can store that form state on the Input itself.

Metadata

Metadata

Assignees

Labels

c: API breakBackwards-incompatible API changesframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions