Force Flutter navigator to reload state when popping

前端 未结 14 2200
情书的邮戳
情书的邮戳 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:12

    The Easy Trick is to use the Navigator.pushReplacement method

    Page 1

    Navigator.pushReplacement(
      context,
      MaterialPageRoute(
        builder: (context) => Page2(),
      ),
    );
    

    Page 2

    Navigator.pushReplacement(
      context,
      MaterialPageRoute(
        builder: (context) => Page1(),
      ),
    );
    

提交回复
热议问题