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();
                            },
                          )

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM