发布于 5年前

flutter 输入框如何获得焦点,移除焦点

FocusNode mFocusNode = FocusNode();

...
TextField(
  focusNode: mFocusNode,
  ...
)

// 移除焦点
mFocusNode.unfocus();
// 获得焦点
FocusScope.of(context).requestFocus(mFocusNode);
// 是否获得焦点的状态
mFocusNode.hasFocus
©2020 edoou.com   京ICP备16001874号-3