Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

docs.flutter.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.

Learn more

Flutter 3.41 is live! Check out theFlutter 3.41 blog post!

The new Form, FormField auto-validation API

Gives more control in how to auto validate a Form and a FormField.

Important

Summary

#

The previous auto validation API for theForm andFormField widgets didn't control when auto validation should occur. So the auto validation for these widgets always happened on first build when the widget was first visible to the user, and you weren't able to control when the auto validation should happen.

Context

#

Due to the original API not allowing developers to change the auto validation behavior for validating only when the user interacts with the form field, we added new API that allows developers to configure how they want auto validation to behave for theForm andFormField widgets.

Description of change

#

The following changes were made:

  • Theautovalidate parameter is deprecated.
  • A new parameter calledautovalidateMode, an Enum that accepts values from theAutovalidateMode Enum class, is added.

Migration guide

#

To migrate to the new auto validation API you need to replace the usage of the deprecatedautovalidate parameter to the newautovalidateMode parameter. If you want the same behavior as before you can use:autovalidateMode = AutovalidateMode.always. This makes yourForm andFormField widgets auto validate on first build and every time it changes.

Code before migration:

dart
classMyWidgetextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnFormField(autovalidate:true,builder:(FormFieldStatestate){returnContainer();},);}}

Code after migration:

dart
classMyWidgetextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnFormField(autovalidateMode:AutovalidateMode.always,builder:(FormFieldStatestate){returnContainer();},);}}

Timeline

#

Landed in version: 1.21.0-5.0.pre
In stable release: 1.22

References

#

API documentation:

Relevant issues:

Relevant PRs:

Was this page's content helpful?

Unless stated otherwise, the documentation on this site reflects Flutter 3.38.6. Page last updated on 2025-10-28.View source orreport an issue.


[8]ページ先頭

©2009-2026 Movatter.jp