颤振:轮廓输入边框 [英] Flutter: Outline input border

查看:58
本文介绍了颤振:轮廓输入边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为文本字段构建边框,例如:

I was trying to build a border for my text field like:

return TextField(
  ...
 border: OutlineInputBorder(
  borderSide: BorderSide(
   color: Colors.red, 
    width: 5.0),
    )
  )
)

但是它总是返回宽度为1.0的黑色边框.我发现改变颜色的唯一方法是创建一个ThemeData,在其中指定提示颜色,但是找不到改变宽度的方法.

But it always return a black border with 1.0 as width. The only way that I found to change the color was to create a ThemeData where I specify the hint color, but I could not find a way to change my width.

推荐答案

您要寻找的是- InputDecoration enabledBorder 属性.

What your looking for is - enabledBorder property of InputDecoration.

如果要更改焦点的边框,请使用- focusedBorder

If you want to Change Border on focus use - focusedBorder

    TextField(
        decoration: new InputDecoration(
            focusedBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.greenAccent, width: 5.0),
            ),
            enabledBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.red, width: 5.0),
            ),
            hintText: 'Mobile Number',
        ),
    ),

这篇关于颤振:轮廓输入边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆