I have a function called showdialog and, for some reason, numberPicker does not update its value in showdialog. I know you can use NumberPickerDialog but I would like to know how to solve it in this case. When I use the numberPicker outside the showdialog it works normally
List intList = [0,0,0,0,0,0];
Scaffold(
appBar: AppBar(),
body: Center(child: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index){
return Container(child: IconButton(
icon: Icon(Icons.alarm),
onPressed: (){
_showdialog(index: index);
},
));
} ),
));
}
_showdialog({int index, int value}){
showDialog<int>(
barrierColor: Colors.black54,
context: context,
builder: (BuildContext context){
return AlertDialog(
content:
FutureBuilder(
future: future,
builder: (context, snapshot) =>
NumberPicker.integer(
initialValue: intList[index],
minValue: 00,
maxValue: 23,
onChanged: (value){
setState(() {
intList[index] = value;
});
},
)));
}
);
}