首页 > 解决方案 > 从另一个屏幕移回屏幕后颤动调用一个函数

问题描述

从另一个屏幕移回一个屏幕后,如何在颤振中调用一个函数?

例如:

屏幕一

function1(){
}

屏幕2

function2(){
//Go back to screen 1 and then call function1()
}

标签: flutter

解决方案


这很简单。

Navigator.push(context, MaterialPageRoute(builder: (context)=> SecondScreen())).then((_){
      // This method gets callback after your SecondScreen is popped from the stack or finished.
      function1();
    });

您还应该参考Flutter Navigation & Routing。


推荐阅读