flutter 输入框如何获得焦点,移除焦点
FocusNode mFocusNode = FocusNode();
...
TextField(
focusNode: mFocusNode,
...
)
// 移除焦点
mFocusNode.unfocus();
// 获得焦点
FocusScope.of(context).requestFocus(mFocusNode);
// 是否获得焦点的状态
mFocusNode.hasFocus
FocusNode mFocusNode = FocusNode();
...
TextField(
focusNode: mFocusNode,
...
)
// 移除焦点
mFocusNode.unfocus();
// 获得焦点
FocusScope.of(context).requestFocus(mFocusNode);
// 是否获得焦点的状态
mFocusNode.hasFocus