Deprecate `DropdownButtonFormField` constuctor parameter `value` in favor of the parameter `initialValue`
Summary
#The value
parameter of the DropdownButtonFormField
constructor was
deprecated in favor of the initialValue
parameter.
Context
#The value
parameter of the DropdownButtonFormField
constructor was used
to initialize DropdownButtonFormField.initialValue
.
Not using the same name was confusing. For example,
developers falsely assumed that setting value
would change
the current selected value. This was not the case—it
only set the initial value or when the field is reset.
Description of change
#The value
parameter of the DropdownButtonFormField
constructor is
deprecated in favor of the parameter named initialValue
.
Migration guide
#Replace the value
parameter of the DropdownButtonFormField
constructor
with the initialValue
parameter to initialize
DropdownButtonFormField.initialValue
.
Code before migration:
DropdownButtonFormField(
value: 'Yellow',
),
Code after migration:
DropdownButtonFormField(
initialValue: 'Yellow',
),
Timeline
#Landed in version: 3.33.0-1.0.pre
In stable release: TBD
References
#API documentation:
Relevant issues:
Relevant PRs:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2025-06-30。 查看文档源码 或者 为本页面内容提出建议.