Search code examples
flutterflutter-dependenciesflutter-animation

invalid constant value in flutter


How to fix this Constant value error

                  actions: [
                IconButton(
                   
                      icon: Icon(
                        Icons.cancel,
                        color: Colors.red,
                      ), onPressed: () { 
                        Navigator.pop(context);
                       },
                    )

              ]

Click Here

I have provided a code snippet for a Flutter application that includes an IconButton widget with an icon for the cancel button. When the button is pressed, the current screen is displayed using Navigator.pop(context) How to implement pop from navigation layer ?


Solution

  • The problem is on your AlertDialog.

    You just need to remove const before AlertDialog.