Flutter Back button with return data

后端 未结 11 1026
长情又很酷
长情又很酷 2020-12-01 15:46

I have an interface with two buttons that pop and return true or false, like so:

onPressed: () => Navigator.pop(context, false)

I need t

11条回答
  •  醉话见心
    2020-12-01 16:37

    This may help and work for you

    1st screen

    void goToSecondScreen()async {
     var result = await Navigator.push(_context, new MaterialPageRoute(
     builder: (BuildContext context) => new SecondScreen(context),
     fullscreenDialog: true,)
    );
    
    Scaffold.of(_context).showSnackBar(SnackBar(content: Text("$result"),duration: Duration(seconds: 3),));
    }
    

    2nd screen

    Navigator.pop(context, "Hello world");
    

提交回复
热议问题