updating values in an alert dialogue or cupertino dialogue
int _n = 0; //counter variable
void add(setState) {
setState(() {
_n++;
});
}
void minus(setState) {
setState(() {
if (_n != 0) _n--;
});
}
void confirmBox() {
showDialog(
context: context,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, StateSetter setState) {
return Container(
child: Scaffold(
body: Column(
children: <Widget>[
Center(
child: Column(
children: <Widget>[
FloatingActionButton(
onPressed: () => add(setState),
child: Icon(
Icons.add,
color: Colors.black,
),
backgroundColor: Colors.white,
),
Text("$_n", //_n value is not updating yet
style: TextStyle(fontSize: 60.0)),
FloatingActionButton(
onPressed: () => minus(setState),
child: Icon(
const IconData(0xe15b,
fontFamily: 'MaterialIcons'),
color: Colors.black),
backgroundColor: Colors.white,
),
],
),
),
],
),
),
);
});
});
}