Flutter:如何检查设备中是否按下主页按钮和电源按钮

发布于 2025-01-18 07:42:35 字数 336 浏览 4 评论 0原文

如何在Flutter应用程序中的Android/iOS设备中按下主页按钮或电源按钮。

有一个软件包 - https://pub.dev/packages/packages/hardware_buttons

颤动2.10。

错误 - “插件`hardware_buttons使用了Android嵌入的不弃用版本。”

我尝试使用它,但它表明它已弃用,因为它正在使用Android V1嵌入。

How to check if the home button or the power button are pressed in an android/ios device in Flutter App.

There is a package - https://pub.dev/packages/hardware_buttons

Now it is not compatible with Flutter 2.10.

Error - "The plugin `hardware_buttons` uses a deprecated version of the Android embedding."

I tried using it, but it is showing that it is deprecated, because it was using Android V1 Embedding.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你只要分分秒秒 2025-01-25 07:42:35

您不需要捕获家庭按钮。如果用户按HOME和其他一些活动出现在Foreground,则您的应用将在您的当前活动中调用背景()。

You do not need to catch Home button. If user press Home and some other Activity comes to foreground, your app goes to background and onPause() is called in your current Activity.override method onpause() and then do what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文