Counter Inside AlertDialog - Flutter
669
The code sample below solved my problem. As @anmol.majhail nicely referred, a wrote my AlertDialog inside a new class, which was then called by the build() function. To call the class and show AlertDialog i used to do this.
Widget createItem() {
return new FloatingActionButton(
elevation: 4.0,
child: const Icon(Icons.create),
onPressed: () {
showDialog(
context: context,
child: new ItemAlertView()
);
},
);
}
This example helped me out (compare to line 59). https://gist.github.com/harshapulikollu/5461844368e95c6d3a38fffe72f03eee
Author by
Adrian
Updated on December 15, 2022Comments
-
Adrian over 1 year
I am using an AlertDialog for my application and inside i build an counter. Value of counter does not get updated automatically. i used "setState({})", but it does not help, because it only rebuilds the build() function and not the int _value inside Dialog.
Anyone familiar to this problem and help me out? Thank you
-
Anthony Sette over 4 yearsPlease share your code so we can help you better.
-
anmol.majhail over 4 yearsYou need to Create a separate Stateful Widget CustomDialog for the AlertDialog. stackoverflow.com/a/54014625/10269042 & stackoverflow.com/a/54948305/10269042
-
-
Adrian over 4 yearsthank you very much for your help. Unfortunately it did not work for me. i found another solution, check it out :)