Flutter - Always execute a function when the page appears

后端 未结 5 1110
暗喜
暗喜 2021-01-20 03:56

How could I make the name() function run whenever the Page1 page appeared?

In the code below before going to Page2 I execute t

5条回答
  •  别那么骄傲
    2021-01-20 04:57

    You can override the back button on the second screen. And instead of system closing, do

    `WillPopScope(
        onWillPop: () {
           print('back pressed');
           Navigator.pop(context, "From BackButton");
           return true;
          },
        child: Scaffold(...)`
    

提交回复
热议问题