Flutter CupertinoPicker initial value from a previous CupertinoPicker's last chosen value

638 Views Asked by At

I have a UI with multiple pickers on the screen. The first one being select an age from the list. When I pass to the second picker where we pick a weight with an initial value of 65 kg, it takes as an initial value last chosen index from the age picker. If the age was chosen 21 years, then an initial value of the weight picker becomes 21 kg. Is there any solvation for it? Because third is sex picker, where I have just two values, but an initial value appears empty because on previous was chosen 75 kg.

1

There are 1 best solutions below

0
On

Found a solution to add key property to widget, so rebuild will run correctly.

return Container(
  key: ValueKey(someUniqueValue), 
  child: ...
);