Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter call a function after moving back to screen from another screen

Tags:

flutter

How to call a function in flutter ,after moving back to a screen from another screen?

For Example:

Screen 1

function1(){
}

Screen2

function2(){
//Go back to screen 1 and then call function1()
}
like image 663
shubham chhimpa Avatar asked Oct 16 '25 20:10

shubham chhimpa


1 Answers

It's simple.

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

You should also refer the Flutter Navigation & Routing.

like image 61
Jay Mungara Avatar answered Oct 18 '25 12:10

Jay Mungara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!