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

Share:
669
Adrian
Author by

Adrian

Updated on December 15, 2022

Comments

  • Adrian
    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

  • Adrian
    Adrian over 4 years
    thank you very much for your help. Unfortunately it did not work for me. i found another solution, check it out :)