Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Return data from a screen

I have two screens. I want a number to be returned from the second screen.

Navigator.pop(context, numder )

How can I make a handler on the first screen?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you need to push like this when you want to receive data from next screen:

onPressed: ()async {
    var result = await Navigator.of(context).push(MaterialPageRoute(builder: (context) => NewScreen()));
    
    if(result != null){
       print(result);
    }
}

by say like this way, I mean call await can return to a variable, not exactly this push.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading