[英]Flutter: How can I pass data back to Navigator when I use iOS swipe back gesture?
How can I pass some data back to Navigator when I close the page with iOS swipe back gesture?当我使用 iOS 向后滑动手势关闭页面时,如何将一些数据传递回 Navigator? If I close the page manually, obviously everything works correctly, because when I close it, I call the Navigator.pop() method and pass the data in the arguments.
如果我手动关闭页面,显然一切正常,因为当我关闭它时,我会调用 Navigator.pop() 方法并在参数中传递数据。 But how do I do this when I go back with swipe gesture?
但是当我用滑动手势返回时我该怎么做?
PS WillPopScope will not help, only relevant for Android. PS WillPopScope 无济于事,仅适用于 Android。
I don't think there's a way to directly pass the result without using Navigator.pop()
.我认为没有办法在不使用
Navigator.pop()
情况下直接传递结果。 I can think of two ways for solving the issue:我可以想到两种解决问题的方法:
Navigator.pop(result)
), then you can distinguish these 2 cases by checking if result of Navigator.push()
is not null.Navigator.pop(result)
),那么您可以通过检查Navigator.push()
结果是否不是来区分这两种情况空值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.