概述
TextField(
style: const TextStyle(color: Color(0xFFA7ABBB),fontSize: 15),
inputFormatters: [DecimalInputFormat(decimalRange: 4)],
keyboardType: TextInputType.numberWithOptions(signed: true),
controller: TextEditingController.fromValue(TextEditingValue(
text: item['number'],
selection: TextSelection.fromPosition(TextPosition(
affinity: TextAffinity.downstream,
offset: item['number'].length)
))
),
decoration: InputDecoration(
counterText: '',
filled: true,
fillColor: Color(0xFF1A1A1A),
hintStyle: const TextStyle(color: Color(0xFFA7ABBB),fontSize: 15),
hintText: '请输入数量',
contentPadding: EdgeInsets.symmetric(horizontal: 15,vertical: 10),
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(6),borderSide: BorderSide.none),
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(6),borderSide: BorderSide.none),
suffixIcon: Container(alignment: Alignment.centerRight,child: Text('XBIT',style: const TextStyle(color: Color(0xFFA7ABBB),fontSize: 15),),margin: EdgeInsets.only(right: 15),),
suffixIconConstraints: BoxConstraints(maxWidth: 80)
),
onChanged: (v){
item['number'] = v;
setState(() { });
},
)
最后
以上就是合适纸飞机为你收集整理的Flutter TextField实现双向绑定的全部内容,希望文章能够帮你解决Flutter TextField实现双向绑定所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复