Force Flutter navigator to reload state when popping

前端 未结 14 2169
情书的邮戳
情书的邮戳 2020-11-28 22:54

I have one StatefulWidget in Flutter with button, which navigates me to another StatefulWidget using Navigator.push(). On second widge

14条回答
  •  醉梦人生
    2020-11-28 23:13

    For me worked:

    ...
    onPressed: (){pushUpdate('/somePageName');}
    ...
    
    pushUpdate (string pageName) async {      //in the same class
      await pushPage(context, pageName);
      setState(() {});
    }
    
    
    //---------------------------------------------
    //general sub
    pushPage (context, namePage) async {
      await Navigator.pushNamed(context, namePage);
    }
    

    In this case doesn't matter how you pop (with button in UI or "back" in android) the update will be done.

提交回复
热议问题