i have a button inside the showmodelbottomsheet that returns a cupertino picket.
higher up i have a textwidget that should return the value selected from the picker. but it only refresh the value when i close the bottomsheet . how can i make the text widget to get the new value everytime the cupertino closes instead?
OutlineButton(
child: Text(
citys[selectedcity]),
onPressed: () =>
showModalBottomSheet(
context:
context,
builder: (BuildContext
context) =>
Container(
color: Colors.white,
height: 200,
width: MediaQuery.of(context).size.width,
child: CupertinoPicker(
onSelectedItemChanged: (int index) {
setState(() {
selectedcity = index;
print(citys[selectedcity]);
});
},
itemExtent: 30,
children: List<Widget>.generate(citys.length, (index) {
return Center(
child: Text(citys[index]),
);
}),
),
)),
),