How to refresh an AlertDialog in Flutter?

前端 未结 5 2404
萌比男神i
萌比男神i 2020-11-27 13:54

Currently, I have an AlertDialog with an IconButton. The user can click on the IconButton, I have two colors for each click. The problem is that I

5条回答
  •  猫巷女王i
    2020-11-27 14:40

    Currently to retrieve the value of Dialog I use

    showDialog().then((val){
    setState (() {}); 
    print (val);
    });
    

    Example 1st screen

        onPressed: () { 
        showDialog(
           context: context,
           barrierDismissible: false,
           builder: (context) {
             return AddDespesa();
           }).then((val) {
             setState(() {});
             print(val);
            }
        );
       }
    

    2nd screen

    AlertDialog(
        title: Text("Sucesso!"),
        content: Text("Gasto resgristrado com sucesso"),
        actions: [
        FlatButton(
          child: Text("OK"),
          onPressed: () {
             Navigator.pop(context, true);
          },
         ),
       ],
     );
    

    Will be printed true,

提交回复
热议问题