flutter ---TextField 之 输入类型、长度限制
TextField想要实现输入类型、长度限制需要先引入import‘package:flutter/services.dart’;
例如
import 'package:flutter/services.dart';
TextField(
keyboardType: TextInputType.number,//键盘类型,数字键盘
style: TextStyle(fontSize: ScreenUtil().setWidth(40), color: Colors.black),//输入文字样式
controller: _cpyCode,//控制器
decoration: InputDecoration(
hintText: '请输入6位公司编号',
hintStyle: TextStyle( fontWeight: FontWeight.w600, fontSize: ScreenUtil().setWidth(40), color: Colors.grey[400]),
border: InputBorder.none,
),
inputFormatters: <TextInputFormatter>[
WhitelistingTextInputFormatter.digitsOnly,//只输入数字
LengthLimitingTextInputFormatter(6)//限制长度
],
onChanged: _listenCpyCode,
)), 相关推荐
csdnYF 2020-11-15
SemiraChen 2020-10-10
YejiaSun 2020-09-27
csdnYF 2020-09-20
FrankAbagnale 2020-09-15
wmd看海 2020-07-27
szintu 2020-07-05
chaoxiao 2020-07-04
wmd看海 2020-06-27
龙衣 2020-06-26
龙衣 2020-06-09
龙衣 2020-06-08
wmd看海 2020-06-04
Samlss 2020-06-04
wmd看海 2020-06-04
csdnYF 2020-05-30
androidgjw 2020-05-28
wmd看海 2020-05-28
wmd看海 2020-05-19