问题描述:
我的TextField加了限制inputFormatters: [LengthLimitingTextInputFormatter(8),FilteringTextInputFormatter.digitsOnly],导致输入不在限制内的内容虽然不显示,但是却需要多次回退才能正常使用
我的解决方案:
var _input = ''; TextEditingController _textFieldController = new TextEditingController();
TextField( maxLines: 1, controller: _textFieldController, //我的限制 inputFormatters: [LengthLimitingTextInputFormatter(8),FilteringTextInputFormatter.digitsOnly], keyboardType: TextInputType.phone, style: TextStyle( fontSize: 16.px, color: WFHelp.mainTextHighlightColor,), cursorColor: WFHelp.mainColor, decoration: InputDecoration( isDense: true, hintText: this.hint, hintStyle: TextStyle(fontSize: 14.px, color: Color(0xff999999)), border: InputBorder.none, filled: true, fillColor: Colors.transparent, ), onChanged: (value) {