flutter TextField隐藏键盘

直接上代码 : 

  TextEditingController _contentController = new TextEditingController();
  FocusNode _contentFocusNode = FocusNode();

 

                  Container(
                    padding: EdgeInsets.fromLTRB(0.00, 5.00, 0.00, 5.00),
                    child: TextField(
                      focusNode: _contentFocusNode,
                      controller: _contentController,
                      style: TextStyle(fontSize: 9.00, color: Colors.black),
                      autocorrect: false,
                      maxLines: 2,
                      decoration: new InputDecoration(
                          labelText: '内容',
                          border: new OutlineInputBorder(
                              borderRadius: new BorderRadius.circular(3.0))),
                      onChanged: (val) {
                        if (val.length > 300) {
                          _newContent = val.substring(0, 300);
                          _contentController.text = _newContent;
                        } else {
                          _newContent = val;
                        }
                      },
                    )..controller.text = _newContent,
                  ),

 

                MaterialButton(
                            child: new Text(_choosedCategory,
                                style: new TextStyle(
                                    color: Colors.amber,
                                    fontSize: 9.00,
                                    letterSpacing: 5.00)),
                            color: Colors.teal,
                            onPressed: () {
                              _contentFocusNode.unfocus();
                              _tieziCategory_flag = true;
                              Navigator.pop(context);
                              _addTieZi();
                            },
                          )

 

posted on 2019-02-02 01:37  --LP--  阅读(8526)  评论(0编辑  收藏  举报

导航