【问题标题】:Programmatically click on home button and turn off screen in flutter以编程方式单击主页按钮并在颤动中关闭屏幕
【发布时间】:2021-03-03 02:20:20
【问题描述】:

如何以编程方式访问主页和电源按钮,我知道关闭屏幕只能由 android 中的系统应用程序访问,但是移动到主屏幕呢,它可以从颤振以编程方式访问吗?如果没有,是否有任何插件可以做那个动作。

【问题讨论】:

    标签: android ios flutter plugins


    【解决方案1】:

    遗憾的是,在 Flutter 中无法关闭屏幕,但您可以执行系统操作:

    使用这个库:

    system_shortcuts: ^1.0.0
    

    像这样导入:

    import 'package:system_shortcuts/system_shortcuts.dart';
    

    然后你可以调用:

    await SystemShortcuts.home();
    

    但是请注意,这需要你调用它的函数是异步的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-20
      • 1970-01-01
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多