Flutter Android TV 应用程序无法使用 D Pad 进行选择

Moh*_*haq 1 android d-pad android-tv flutter flutter-layout

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

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

快捷方式(

    shortcuts: {
      LogicalKeySet(LogicalKeyboardKey.select):
          const Intent(ActivateAction.key)
    },
    child: MaterialApp())
Run Code Online (Sandbox Code Playgroud)

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

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

apc*_*apc 6

添加此代码对于 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( 
Run Code Online (Sandbox Code Playgroud)