如何更新颤振TextField的高度和宽度?

前端之家收集整理的这篇文章主要介绍了如何更新颤振TextField的高度和宽度?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在Flutter中自定义TextField布局的高度和宽度?

解决方法

要调整宽度,可以使用Container小部件包装TextField,如下所示:

new Container(              
  width: 100.0,child: new TextField()
)

我不太确定你在TextField的高度时所追求的是什么,但是你可以看看TextStyle小部件,你可以使用它来操纵fontSize和/或高度

new Container(              
  width: 100.0,child: new TextField(                                 
    style: new TextStyle(
      fontSize: 40.0,height: 2.0,color: Colors.black                  
    )
  )
)

请记住,TextStyle中的高度是字体大小的乘数,根据属性本身的注释:

The height of this text span,as a multiple of the font size.

If applied to the root [TextSpan],this value sets the line height,
which is the minimum distance between subsequent text baselines,as
multiple of the font size.

最后但并非最不重要的,您可能想看看TextField的装饰属性,它为您提供了很多可能性

编辑:如何更改TextField的内部填充/边距

您可以使用TextDeield的InputDecoration和decoration属性.例如,你可以这样做:

new TextField(                                
    decoration: const InputDecoration(
        contentPadding: const EdgeInsets.symmetric(vertical: 40.0),)
)

猜你在找的Flutter相关文章