Home > Software design >  Return data from a screen
Return data from a screen

Time:12-15

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?

CodePudding user response:

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.

  • Related