Flutter Desktop:如何捕捉关闭按钮? [英] Flutter desktop: How to catch closure button?

查看:155
本文介绍了Flutter Desktop:如何捕捉关闭按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Flutter的桌面应用程序(Windows),如果用户尝试使用关闭"按钮关闭窗口,则需要设置AlertDialog.

I'm working on a desktop application with flutter (Windows), I need to set up an AlertDialog if the user tries to close the window with the close button.

如果有人有想法甚至解决方案,我会接受:D

If someone has an idea or even a solution, I'll take it :D

我在下面附上了参考图片.

I have attached a reference image below.

此按钮

推荐答案

当前没有内置的挂钩可以让您处理关闭窗口的尝试.请参见此问题.您需要自己实现它,方法是将 WM_CLOSE 处理程序添加到 win32_window.cpp ,取消关闭,然后使用 MethodChannel 调用Dart(或其他类似的机制),然后如果Dart的响应指示该窗口应该关闭,则将其直接销毁.

There is currently no built-in hook that lets you handle window close attempts; see this issue. You'd need to implement it yourself by adding a WM_CLOSE handler to win32_window.cpp, canceling the close, calling into Dart with a MethodChannel (or another similar mechanism), and then if the response from Dart indicates the window should be closed, destroying it directly.

这篇关于Flutter Desktop:如何捕捉关闭按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆