Flutter Back button with return data

后端 未结 11 1013
长情又很酷
长情又很酷 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条回答
  •  萌比男神i
    2020-12-01 16:14

    The simplest way to achieve this is to :

    In your body take a WillPopScope as the parent widget And on its onWillPop : () {} call

    Navigator.pop(context, false);
    

    onWillPop of WillPopScope will be triggered automatically when you’ll press the back button on your AppBar

提交回复
热议问题