前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【Flutter 专题】65 图解基本 TextField 文本输入框 (二)

【Flutter 专题】65 图解基本 TextField 文本输入框 (二)

作者头像
阿策小和尚
发布于 2019-10-28 10:02:54
发布于 2019-10-28 10:02:54
4.7K00
代码可运行
举报
文章被收录于专栏:阿策小和尚阿策小和尚
运行总次数:0
代码可运行

和尚刚学习了 TextField 的基本用法,今天特意学习一下 TextField InputDecoration 文本框装饰器的相关内容;

InputDecoration 源码分析

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
const InputDecoration({
    this.icon,                  // 装饰器外小图标
    this.labelText,             // 文本框描述标签
    this.labelStyle,            // 文本框描述标签样式
    this.helperText,            // 文本框辅助标签
    this.helperStyle,           // 文本框辅助标签样式
    this.hintText,              // 文本框默认提示信息
    this.hintStyle,             // 文本框默认提示信息样式
    this.hintMaxLines,          // 文本框默认提示信息最大行数
    this.errorText,             // 文本框错误提示信息
    this.errorStyle,            // 文本框错误提示信息样式
    this.errorMaxLines,         // 文本框错误提示信息最大行数
    this.hasFloatingPlaceholder = true,     // 文本框获取焦点后 labelText 是否向上浮动
    this.isDense,               // 是否问紧凑型文本框
    this.contentPadding,        // 文本内边距
    this.prefixIcon,            // 前置图标
    this.prefix,                // 前置预填充 Widget
    this.prefixText,            // 前置预填充文本
    this.prefixStyle,           // 前置预填充样式
    this.suffixIcon,            // 后置图标
    this.suffix,                // 后置预填充 Widget
    this.suffixText,            // 后置预填充文本
    this.suffixStyle,           // 后置预填充样式
    this.counter,               // 输入框右下角 Widget
    this.counterText,           // 输入框右下角文本
    this.counterStyle,          // 输入框右下角样式
    this.filled,                // 是否颜色填充文本框
    this.fillColor,             // 填充颜色
    this.errorBorder,           // errorText 存在时未获取焦点边框
    this.focusedBorder,         // 获取焦点时边框
    this.focusedErrorBorder,    // errorText 存在时获取焦点边框
    this.disabledBorder,        // 不可用时边框
    this.enabledBorder,         // 可用时边框
    this.border,                // 边框
    this.enabled = true,        // 输入框是否可用
    this.semanticCounterText,
    this.alignLabelWithHint,    // 覆盖将标签与 TextField 的中心对齐
})

const InputDecoration.collapsed({
    @required this.hintText,
    this.hasFloatingPlaceholder = true,
    this.hintStyle,
    this.filled = false,
    this.fillColor,
    this.border = InputBorder.none,
    this.enabled = true,
})

分析源码可知,Flutter 不仅提供了全面的构建装饰器的方式,还提供了简单便利的构建方式 collapsed 默认是无边框的,且无法设置标签等其他属性;

案例尝试

  1. icon 为装饰器外小图标,可灵活设置图标或其他 Widget,默认距输入框 16dp,主题可通过 IconTheme 设置;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(icon: Image.asset('images/ic_launcher.png')));
return TextField(decoration: InputDecoration(icon: Icon(Icons.android)));
  1. labelText 为文本框描述标签,为 String 类型,直接编辑内容即可;labelStyle 为标签样式属性;TextField 获取焦点之后描述标签上移;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple)));
  1. helperText 为文本框辅助标签,一般在文本框底部,提示性内容;helperStyle 为文本框辅助标签样式属性;与 TextField 是否获取焦点无变化;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    helperText: '请输入手机号或邮箱!', helperStyle: TextStyle(color: Colors.teal)));
  1. hintText 为文本框默认提示信息,若设置 labelText,则 TextField 在未获取焦点时优先展示 labelTexthintStyle 为文本框提示信息样式属性;hintMaxLines 为提示信息过长时允许展示的最大行数;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(
    hintStyle: TextStyle(color: Colors.brown), hintMaxLines: 1, hintText: '请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!'));

return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    helperText: '请输入手机号或邮箱!', helperStyle: TextStyle(color: Colors.teal),
    hintText: '请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!',
    hintStyle: TextStyle(color: Colors.brown), hintMaxLines: 2));
  1. errorText 为文本框错误提示信息,一般在文本框底部,当设置 errorText 时不展示 helperText,整体默认为红色;errorStyle 为错误提示信息样式属性;errorMaxLines 为错误信息过长时允许展示的最大行数;与 hintText 类似;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(onChanged: (text) { setState(() { _textLength = text.length; }); },
    decoration: InputDecoration(
        labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
        helperText: '请输入手机号或邮箱!', helperStyle: TextStyle(color: Colors.teal),
        hintText: '请输入用户名信息!', hintStyle: TextStyle(color: Colors.brown),
        errorText: _textLength > 11 ? '请勿超过 11 位用户名!' : null, errorStyle: TextStyle(color: Colors.pink)));
  1. hasFloatingPlaceholder 设置 TextField 获取焦点时 labelText 是否向上浮动;设置为 false 时,获取焦点后 labelText 隐藏,不会向上浮动;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    hasFloatingPlaceholder: false));
  1. isDense 是否为紧凑型文本框,true 为紧凑型文本框,图标等与输入框边距较小;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(icon: Icon(Icons.android), isDense: false));
return TextField(decoration: InputDecoration(icon: Icon(Icons.android), isDense: true));
  1. contentPadding 为编辑内容与文本框内边距;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
returnTextField(decoration: InputDecoration(contentPadding: EdgeInsets.all(20.0)));
  1. prefix… 是文本框前置组件,prefixIcon 为前置图标,固定在文本输入框前边,与 icon 位置不同,其样式通过 IconTheme 调整;prefixText 为前置预填充文本,例如手机号前(+86) 之类;prefix 为前置预填充组件,可自由设置,更为灵活,但不能与 prefixText 同时使用;prefixStyle 为预填充组件样式;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(
    prefixIcon: Icon(Icons.supervised_user_circle), prefixText: '(+86)', prefixStyle: TextStyle(color: Colors.purple.withOpacity(0.4))));

return TextField(decoration: InputDecoration(
    prefixIcon: Icon(Icons.supervised_user_circle), prefixStyle: TextStyle(color: Colors.purple.withOpacity(0.4)),
    prefix: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[Icon(Icons.phone), Text('(+86)')])));
  1. suffix… 为文本框后置组件系列;与 prefix… 用法一致;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(
    suffixIcon: Icon(Icons.close), suffixText: '关闭', suffixStyle: TextStyle(color: Colors.purple.withOpacity(0.4))));

return TextField(decoration: InputDecoration(
    suffixIcon: Icon(Icons.close), suffixStyle: TextStyle(color: Colors.purple.withOpacity(0.4)),
    suffix: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[Text('关闭'), Icon(Icons.remove_red_eye)])));
  1. counter 系列为文本框右下角计数器,当设置 maxLengths 时通常会在右下角展示编辑字符数与整体数量比,可通过 counter 系列组件调整;counterText 为计数器展示内容;counterStyle 为计数器样式属性;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(maxLength: 20,
    decoration: InputDecoration(counterText: '最大长度不超过20', counterStyle: TextStyle(color: Colors.blueAccent)));
  1. filled 为文本框是否颜色填充,只有 true 时,filledColor 才生效;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(fillColor: Colors.green.withOpacity(0.4), filled: true));
  1. enabled 为文本框是否可用,false 为不可用,无法获取焦点;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(enabled: false));
  1. alignLabelWithHint 用于 TextField 设置多行时,true 时覆盖将标签与 TextField 的中心对齐的默认行为,和尚尝试了多种情况下 truefalse 状态,发现效果并不明显,有待继续研究;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(maxLines: null, decoration: InputDecoration(
  alignLabelWithHint: true, labelText: '用户名:',
  hintMaxLines: null, helperText: '请输入手机号或邮箱!',
  hintText: '请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!请输入用户名信息!',
));
  1. border 为一个系列,包括各种环境下边框;默认 border 为正常状态下边框;边框基本包括三类:

a. InputBorder 一般设置为无边框样式;

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(border: InputBorder.none));

b. UnderlineInputBorder 一般设置为底部一条直线边框样式;和尚测试时设置边框圆角为 10dp 加上背景色效果更明显;

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(
    filled: true, fillColor: Colors.green.withOpacity(0.4),
    border: UnderlineInputBorder(
        borderRadius: BorderRadius.all(Radius.circular(10.0)),
        borderSide: BorderSide(color: Colors.purple, width: 4.0, style: BorderStyle.solid))));

c. OutlineInputBorder 一般设置为包围的圆角边框;相较于 UnderlineInputBorder 多了 gapPadding 属性,用于浮动的 labelText 与边框的间距;

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    border: OutlineInputBorder(
        gapPadding: 10.0, borderRadius: BorderRadius.all(Radius.circular(10.0)), 
        borderSide: BorderSide(color: Colors.purple, width: 4.0, style: BorderStyle.solid))));

和尚测试发现 UnderlineInputBorderOutlineInputBorder 对于设置 border 边框颜色无效,需要通过 ThemeData 来更改属性;

  1. enabledBorder 为可用时边框样式,enabledtrue

Tips:

  1. errorText 存在时 enabledBorder 不生效;
  2. 若不设置其他 border 属性,获取焦点默认是 ThemeData 中焦点边框,设置 borderfocusedBorder 等生效;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
// UnderlineInputBorder 类型且只设置 enabledBorder
return TextField(decoration: InputDecoration(filled: true,fillColor: Colors.green.withOpacity(0.4),
    enabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple, width: 4.0))));
// UnderlineInputBorder 类型且设置 enabledBorder 和 border
return TextField(decoration: InputDecoration(filled: true, fillColor: Colors.green.withOpacity(0.4),
    enabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple, width: 4.0)),
    border: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)))));
// UnderlineInputBorder 类型且 errorText 不为空
return TextField(decoration: InputDecoration(filled: true, fillColor: Colors.green.withOpacity(0.4),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    enabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple, width: 4.0)),
    border: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)))));
// OutlineInputBorder 类型且只设置 enabledBorder
return TextField(decoration: InputDecoration(labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple.withOpacity(0.4), width: 3.0)),
    border: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)))));
// OutlineInputBorder 类型设置 enabledBorder,且 errorText 不为空
return TextField(decoration: InputDecoration(labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple.withOpacity(0.4), width: 3.0))));
// OutlineInputBorder 类,设置 enabledBorder 和 border 且 errorText 不为空  
return TextField(decoration: InputDecoration(labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple.withOpacity(0.4), width: 3.0)),
    border: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)))));
  1. disabledBorder 为不可用时边框,enabledfalse;且 errorText 存在时 disabledBorder 不生效;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
// UnderlineInputBorder 类型
return TextField( decoration: InputDecoration(enabled: false,
    filled: true, fillColor: Colors.green.withOpacity(0.4),
    disabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0))));
// UnderlineInputBorder 类型且设置 errorText
return TextField(decoration: InputDecoration(enabled: false,
    filled: true, fillColor: Colors.green.withOpacity(0.4),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    disabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0)));
// OutlineInputBorder 类型
return TextField(decoration: InputDecoration(enabled: false,
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    disabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.green, width: 4.0))));
// OutlineInputBorder 类型且设置 errorText
return TextField(decoration: InputDecoration(enabled: false,
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    disabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0))));
  1. focusedBorder 为获取焦点时边框,errorText 存在时 focusedBorder 不生效;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
// UnderlineInputBorder 类型
return TextField(decoration: InputDecoration(
    filled: true, fillColor: Colors.green.withOpacity(0.4),
    focusedBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0)),
    enabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple, width: 4.0))));
// UnderlineInputBorder 类型且设置 errorText
return TextField(decoration: InputDecoration(
    filled: true, fillColor: Colors.green.withOpacity(0.4),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    focusedBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0)),
    enabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple, width: 4.0))));
// OutlineInputBorder 类型
return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple.withOpacity(0.4), width: 3.0)),
    focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.green, width: 4.0))));
// OutlineInputBorder 类型且设置 errorText
return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0)),
    enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple.withOpacity(0.4), width: 3.0))));
  1. errorBordererrorText 不为空且未获取焦点时边框;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
// UnderlineInputBorder 类型
return TextField(decoration: InputDecoration(
    filled: true, fillColor: Colors.green.withOpacity(0.4),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    errorBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.black.withOpacity(0.4), width: 4.0))));
// OutlineInputBorder 类型
return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    errorBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.black.withOpacity(0.4), width: 3.0))));
  1. focusedErrorBordererrorText 不为空且获取焦点时边框;
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
// UnderlineInputBorder 类型
return TextField(decoration: InputDecoration(
    filled: true, fillColor: Colors.green.withOpacity(0.4),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    focusedErrorBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.teal, width: 4.0)),
    errorBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.black, width: 4.0))));
// OutlineInputBorder 类型
return TextField(decoration: InputDecoration(
    labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
    errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink),
    focusedErrorBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0)),
    errorBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.purple.withOpacity(0.4), width: 3.0))));

小扩展

在实际开发中,可能会随时需要关闭键盘,此时我们仅需监听一下即可;和尚监听一个文本输入框,当输入字符长度大于 11 位时即收起键盘;

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
return TextField(controller: controller,
    decoration: InputDecoration(
        labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple),
        errorText: '请勿超过 11 位!', errorStyle: TextStyle(color: Colors.pink)));

void initState() {
  super.initState();
  controller.addListener(() {
    setState(() {
      if (controller.text.length >= 11) {
        // 收起键盘
        FocusScope.of(context).requestFocus(FocusNode());
      }
    });
  });
}

文本输入框确实有很多细节需要研究和尝试,和尚仅初步了解,有待深入研究;且和尚建议时常升级 Flutter 版本,可能对于同一个 Widget 会有或多或少的更新,如有问题请多多指导!

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-10-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 阿策小和尚 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
【Flutter实战】文本组件及五大案例
老孟导读:大家好,这是【Flutter实战】系列文章的第二篇,这一篇讲解文本组件,文本组件包括文本展示组件(Text和RichText)和文本输入组件(TextField),基础用法和五个案例助你快速掌握。
老孟Flutter
2020/09/11
7.4K0
【Flutter实战】文本组件及五大案例
Flutter 中 TextField 组件必然会遇到的问题
TextField 组件几乎是开发中必然会用到的一个组件,在使用的过程中会遇到两个非常棘手的问题:
老孟Flutter
2021/11/25
3.2K0
Flutter 中 TextField 组件必然会遇到的问题
Flutter 全栈式——基础控件
当输入框的默认线框无法满足时,可以使用Container容器自定义边框。这时候可以将装饰器设置为InputDecoration.collapsed(hintText: 'hint')表示禁用装饰线
arcticfox
2020/06/12
3.9K0
Flutter TextField详解
TextField是一个material design风格的输入框,本身有多种属性,除此之外装饰器InputDecoration也有多种属性,但都比较简单,所以不必担心,且听我娓娓道来。
yechaoa
2022/06/10
4.4K0
Flutter TextField详解
Flutter 金融应用程序的 UI
在本教程中,我将向您展示如何使用 Flutter 和 android studio
徐建国
2021/08/03
7950
TextField suffixIcon点击时TextField 选中弹出键盘<Flutter Bug篇>
登录页面有输入密码,常规隐藏显示。但是点击后面小眼睛的时候,TextField会被选中,弹出键盘。
星宇大前端
2020/09/07
2.6K0
TextField  suffixIcon点击时TextField 选中弹出键盘<Flutter Bug篇>
Flutter中的文本输入框组件TextField
1. maxLines 最大输入行。默认为单行输入框,配置此参数后则为多行输入框;
越陌度阡
2021/01/05
5.3K0
Flutter中的文本输入框组件TextField
【Flutter 专题】64 图解基本 TextField 文本输入框 (一)
和尚最近在学习基础的 Flutter Widget,原因在于很多基础的组件有很多容易忽视的注意事项,了解并熟悉后对整体的开发认知会有所提升;今天和尚学习一下 TextField 文本输入框;
阿策小和尚
2019/10/22
4.9K0
[- Flutter 数据&状态篇 -] setState
0.1:对我而言,一个产品有四层境界 1.造都造不出来 2.它又不是不能用 <---- 3.用的时候大家都不说话 4.如丝般顺滑,易拓展,易修改,易复用 0.2:要说的话 注意:本篇是对状态
张风捷特烈
2020/04/30
1.4K0
[- Flutter 数据&状态篇 -] setState
Flutter ShapeBorder 使用总结
ShapeBorder 用于设置形状和轮廓,比如圆形,矩形,圆角矩形等。常用于 Container 中。
徐建国
2021/08/09
2.3K0
【Flutter 专题】62 图解基本 Button 按钮小结 (二)
和尚继续尝试 Flutter 的基本按钮;今天和尚学习 MaterialButton 系列相关 Button;该系列以 MaterialButton 为父类,衍生出 RaisedButton 凸起按钮,FlatButton 扁平按钮和 OutlineButton 边框按钮;可根据不同场景灵活运用;
阿策小和尚
2019/09/25
1.4K0
【Flutter 专题】62 图解基本 Button 按钮小结 (二)
Flutter组件学习(三)—— 输入框TextFiled
Google 前两天发布了 Flutter 1.0 正式版本,正式版发布之后,LZ身边越来越多的人都开始入坑了,不得不说 Flutter 框架的魅力还是很吸引人的哈,所以我们更要抓紧学习了;之前我写了两篇文章来介绍 Flutter中的Text组件 和 Flutter中的Image组件,今天我们继续学习输入框 TextFiled 组件,话不多说,先上图:
用户2802329
2018/12/26
2.6K0
Flutter | 常用组件
​ textAlign:文本的对齐方式;可以选择左对齐、右对齐还是居中。注意,对齐的参考系是Text widget本身
345
2022/02/11
11.6K0
Flutter | 常用组件
Flutter 入门指北之输入处理(登录界面实战)
这边需要提下的是 setState 方法,该方法只有 StatefulWidget 才有,当需要修改某个值的内容的时候,通过该方法进行修改,最后的效果图如下,当输入框文字发生变化的时候,监听的 Text 内容会随之改变,获取内容的 Text 当点击按钮了才发生变化
陈宇明
2020/12/16
2K1
Flutter 意见输入框
在我们输入文本之后下面的输入字数会变,可能马上你会想到使用setState不就完了嘛!....可是Dialog 并没有setState方法
赵哥窟
2021/03/02
2K0
Flutter 意见输入框
Flutter lesson 8:输入框,时间日期选择
Flutter自带的 showDatePicker 和 showTimePicker 两个方法可以进行时间和日期的选择。
踏浪
2019/07/31
4.9K0
Flutter lesson 8:输入框,时间日期选择
Flutter TextField(输入控件)
可以更改角落的光标颜色,宽度和半径。 例如,这里我没有明显的原因制作一个圆形的红色光标。
毛大姑娘
2020/09/10
3.5K0
Flutter TextField(输入控件)
Flutter中的常见表单组件
在Flutter中,常见的表单组件有TextField单行文本框、TextField多行文本框、CheckBox、Radio、Switch、CheckBoxListTile、RadioListTile、SwitchListTile、Slide等。
拉维
2019/08/29
5K0
Flutter中的常见表单组件
Flutter 实现登录 UI
本文,我将解析怎么前构建一个用户交互的登录页面。这里,我使用 TextField 挂件,这方便用户输入用户名和密码。还使用 FlatButton 挂件,来处理一些动作。当然,我还使用了 Image 挂件来设定登录页面的 logo。
Jimmy_is_jimmy
2022/10/05
8360
Flutter 实现登录 UI
Flutter 登录页面
Simulator Screen Shot - iPhone 11 Pro Max - 2019-09-26 at 14.03.32.png
赵哥窟
2019/09/27
2.7K0
Flutter 登录页面
相关推荐
【Flutter实战】文本组件及五大案例
更多 >
领券
💥开发者 MCP广场重磅上线!
精选全网热门MCP server,让你的AI更好用 🚀
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档