0

For the elevated button, I would like to show the visible/hide part content through setState. However, I could do it in normal pages but not a Dialog. Here's the code:

                        bool addmaterial = true;

                        ClipRRect(
                                   borderRadius: BorderRadius.circular(50),
                                   child: SizedBox(
                                     height: 40,
                                     width: 400,
                                     child: ElevatedButton(
                                       style: ButtonStyle(
                                         backgroundColor:
                                             MaterialStateProperty.all<Color>(
                                                 Color(0xfff4f4f4)),
                                       ),
                                       onPressed: () {
                                         addmaterial = !addmaterial;
                                       },
Jahidul Islam
  • 11,435
  • 3
  • 17
  • 38

1 Answers1

0

Try adding a StateFulBuilder inside your showDialog widget. If you want to change the state inside the showDialog

  showDialog(
    context: context,
    builder: (BuildContext context) {
      return StatefulBuilder(
        builder: (context, setState) {
          return AlertDialog(
            actions: <Widget>[],
            content: Container(),
          );
        },
      );
    },
  );
Raine Dale Holgado
  • 2,932
  • 2
  • 17
  • 32