如何聆听颤动中的焦点变化? [英] How to listen focus change in flutter?
问题描述
在Android中,我们可以调用 setOnFocusChangeListener()
,在 onFocusChanged()
方法中进行操作,但是flutter可以而不是GestureDetector中的 onFocus()
接口,例如 onTap()
或 onKey()
在RawKeyboardListener中。
In Android, we can call setOnFocusChangeListener()
, do something in onFocusChanged()
method, but flutter does not provider onFocus()
interface like onTap()
in GestureDetector or onKey()
in RawKeyboardListener.
我已经阅读了关于焦点的Flutter api, https://docs.flutter.io/flutter/widgets/FocusManager-class.html
,但是我找不到实现我自己的方法请求,有人可以帮我吗?
I have read flutter api about focus, https://docs.flutter.io/flutter/widgets/FocusManager-class.html but I can't find a way to realize my request, anyone who can give me a hand?
推荐答案
我想您正在寻找 FocusNode 类。使用 addListener
方法添加一个侦听器函数,以侦听焦点变化。
I suppose you are looking for FocusNode class. Use addListener
method to add a listener function that listens to focus change.
这篇关于如何聆听颤动中的焦点变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!