检测并阻止用户将当前页面放在扑朔迷离中?
我想检测用户何时试图离开当前页面,并可能阻止他们进行扑打。
I want to detect when a user tries to leave the current page and probably stop them from doing so in flutter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
欢迎来到堆栈溢出,
您可以使用WillPopsCope小部件来实现这一目标。
以下是实现此目标的代码示例。
其中
允许Pop
可以是一个变量,您可以用来检查是否允许用户离开页面。welcome to stack overflow,
You can achieve this by using the WillPopScope Widget.
Below is a code sample to achieve this.
Where
allowPop
can be a variable you can use to check if to allow user to leave the page or not.您可以在
WillPopsCope
的帮助下进行此操作。You can do this with the help of
WillPopScope
.