首页 > 解决方案 > 如何制作可调整大小的TextField?

问题描述

我想让 TextField 可以垂直调整大小,对此我有一个想法

Expanded(
    child: TextField(
        cursorColor: Colors.black,
        decoration: new InputDecoration.collapsed(
//                                      border: new OutlineInputBorder(
//                                          borderSide: new BorderSide(color: hexToColor('#5c6277'),style: BorderStyle())
//                                      ),
            hintText: "El Baraka",hintStyle: TextStyle(fontFamily: 'RobotoLight',color: Colors.grey,fontSize: 16),
    ),
),

在此处输入图像描述

标签: flutterdart

解决方案


这可以通过以下方式实现maxLines: null

TextField(
  cursorColor: Colors.black,
  decoration: new InputDecoration.collapsed(
    hintText: "El Baraka",hintStyle: TextStyle(fontFamily: 'RobotoLight',color: Colors.grey,fontSize: 16),
  ),
  maxLines: null,
)

现在TextField将在您的文本到达边缘时添加一个新行。


推荐阅读