how to return data from cupertino picker to bottomsheet?

148 views
Skip to first unread message

Error Place

unread,
Jun 19, 2020, 8:18:37 AM6/19/20
to Flutter Development (flutter-dev)
hey guys. 
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?
best regards all


this is the code. 



 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]),
);
}),
),
)),
),
Reply all
Reply to author
Forward
0 new messages