Flutter TextField 设置输入类型

Flutter中TextField的输入类型通过keyboardType属性来设置,比如设置成文本、数字、电话、邮箱等类型

例如如下代码限制输入类型为数字

TextField(
  keyboardType: TextInputType.number,
  decoration: InputDecoration(
    labelText: "账号",
    hintText: "请输入账号",
  ),
),

TextInputType还有如下几种输入类型:

  • TextInputType.number:数字
  • TextInputType.visiblePassword:
  • TextInputType.text:文本
  • TextInputType.datetime:时间
  • TextInputType.emailAddress:邮箱
  • TextInputType.multiline:
  • TextInputType.numberWithOptions:
  • TextInputType.phone:电话
  • TextInputType.url:url类型

 

posted @ 2019-10-25 16:56  野猿新一  阅读(432)  评论(0编辑  收藏  举报