I'm encountering an issue in my Flutter app where the initial value of a Dropdown TextField fails to update when I call setState. To reproduce the problem, I've created a Flutter project, set an initial value for the Dropdown, and then attempted to change the value within a setState function. However, despite expecting the Dropdown to reflect the new value after setState, it consistently retains its initial value. This issue persists even though I've ensured the state variable changes correctly within setState.
`
DropDownValueModel list = DropDownValueModel(
name: index[i].name,
value: index[i].id);
setState((){
name=index[0];
});
//BUT GET VALUE FROM 'name' VARIABLE
DropDownTextField(
dropDownList: list,
initialValue: name, //NOT UPDATED
),
`
I would greatly appreciate guidance or solutions to address this unexpected behavior. Thank you!
@AravinthC-18 The initial value will be updated only on the first render. After that, if you want to add a value, use the controller.
controller.setDropDown(value)
I'm encountering an issue in my Flutter app where the initial value of a Dropdown TextField fails to update when I call
setState
. To reproduce the problem, I've created a Flutter project, set an initial value for the Dropdown, and then attempted to change the value within asetState
function. However, despite expecting the Dropdown to reflect the new value aftersetState
, it consistently retains its initial value. This issue persists even though I've ensured the state variable changes correctly withinsetState
. ` DropDownValueModel list = DropDownValueModel( name: index[i].name, value: index[i].id);setState((){ name=index[0]; }); //BUT GET VALUE FROM 'name' VARIABLE DropDownTextField( dropDownList: list, initialValue: name, //NOT UPDATED ), ` I would greatly appreciate guidance or solutions to address this unexpected behavior. Thank you!