如何让 flutter 应用程序支持电视设备?

How to let flutter apps support TV device?

电视设备不支持触摸操作,用户必须使用遥控器。我们需要通过按左、上、右、下方向键来移动焦点,当目标控件获得焦点时,我们将按下 OK 按钮来响应各种按键事件。但是我找不到任何flutter接口来解决这个交互,谁能帮帮我?

有用于此的 SystemChannels。 我自己还没有尝试过,但看起来这应该可以满足您的需要:

DartDocs - SystemChannels.keyEvent

A JSON BasicMessageChannel for keyboard events.

[DartDocs - SystemChannels.textInput[(https://www.dartdocs.org/documentation/flutter/0.0.41-dev/services/SystemChannels/textInput-constant.html)

A JSON MethodChannel for handling text input.

This channel exposes a system text input control for interacting with IMEs (input method editors, for example on-screen keyboards). There is one control, and at any time it can have one active transaction. Transactions are represented by an integer. New Transactions are started by TextInput.setClient. Messages that are sent are assumed to be for the current transaction (the last "client" set by TextInput.setClient). Messages received from the shell side specify the transaction to which they apply, so that stale messages referencing past transactions can be ignored.

后者用于https://github.com/flutter/flutter/blob/4389f07024a4c69f7223401abd4d0ab3ecc45698/packages/flutter/lib/src/services/text_input.dart

物理键盘存在已知问题,可能会导致此用例无法正常工作

是的,Flutter 不支持 D-pad 导航 yet.But,我有一台 Android 智能电视,如果我连接蓝牙鼠标,我可以导航、滑动、在电视上点击等我的 Flutter 应用程序。