[Flutter]输入框获取焦点和失去焦点事件

FocusNode _focusNode = FocusNode();

  @override
  void initState() {
    _focusNode.addListener(() {
      if (!_focusNode.hasFocus) {
        // TextField has lost focus
       //收回键盘
    FocusScope.of(context).requestFocus(FocusNode());
      }
    });
    super.initState();
  }

你可能感兴趣的:(flutter)