Home > Software engineering >  How to refresh datatable from alertdialog in flutter?
How to refresh datatable from alertdialog in flutter?

Time:04-22

I am trying to use an AlertDialog to add rows to a DataTable through a list of class values. However, the DataTable does not seem to be adding new rows when I add into the list of class values even though I'm doing it inside setState.

CodePudding user response:

You need to wait until the popUp is pop and then setState.

For example:

Future showPopUp()async{
   await showDialog(YourDialogHere());
   setState((){});
}

If it does not work with you, please share your code so it can be debugged in detail.

CodePudding user response:

When you close the popup you can return a value and you can handle this value.

Navigator.pop(context, true);
  • Related