From e1eaad17ad8f00be846bf0ddc54c323b70d176a3 Mon Sep 17 00:00:00 2001 From: Mohammad Hamdan Date: Wed, 28 Aug 2024 04:42:10 +0300 Subject: [PATCH] [Doc] [Enhancement] Add more clarification to initial value documentation for form (#153757) When you change the `initialValue` of a `TextFormField`, it will not trigger a widget rebuild, which is the intended behavior. This PR is meant to clarify that. https://github.com/flutter/flutter/issues/152816 --- packages/flutter/lib/src/widgets/form.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index 81b5f81ee7..525cd02b54 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -510,6 +510,11 @@ class FormField extends StatefulWidget { /// /// This is called `value` in the [DropdownButtonFormField] constructor to be /// consistent with [DropdownButton]. + /// + /// The `initialValue` affects the form field's state in two cases: + /// 1. When the form field is first built, `initialValue` determines the field's initial state. + /// 2. When [FormFieldState.reset] is called (either directly or by calling + /// [FormFieldState.reset]), the form field is reset to this `initialValue`. final T? initialValue; /// Whether the form is able to receive user input.