首页 > 解决方案 > Flutter Android TV 应用无法使用 D Pad 进行选择

问题描述

我正在使用 Flutter 开发 Android TV 应用程序。我能够运行该应用程序(现在是示例应用程序)。但我无法使用 d pad 选择按钮选择任何内容。

我发现我必须使用这样的东西才能实现这一点

捷径(

    shortcuts: {
      LogicalKeySet(LogicalKeyboardKey.select):
          const Intent(ActivateAction.key)
    },
    child: MaterialApp())

但它在代码中给了我一个错误。我究竟做错了什么?

任何帮助表示赞赏。谢谢你。

标签: androidflutterflutter-layoutandroid-tvd-pad

解决方案


添加此代码肯定有助于 Android TV OK/Select 按钮,并且可以扩展为其他映射。为 Flutter 1.24-dev 构建并完美运行

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return Shortcuts(
      shortcuts: <LogicalKeySet, Intent>{
        LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(),
      },
      child: MaterialApp( 

推荐阅读