首页 > 解决方案 > TextFormField 通过适当的对齐增加高度

问题描述

我正在努力让我TextFormField的“更大”。我试过这段代码,它确实让它变大了,但如果我输入(这里:qwerty)它从中间开始。有没有从左上角开始的选项?

Padding(
  padding: EdgeInsets.only(top: 8.0),
  child: Container(
    width: screenWidth / 1.1,
    height: screenHeight / 5.5,
    child: Form(
      key: _form2Key,
      autovalidate: true,
      child: TextFormField(
        validator: (val) {
          if (val.trim().length > 200) {
            return "Beschrijving te lang";
          } else {
            return null;
          }
        },
        onSaved: (val) => beschrijving = val,
        minLines: null,
        maxLines: null,
        expands: true,
        decoration: InputDecoration(
          border: OutlineInputBorder(),
          filled: true,
          fillColor: Colors.white,
          labelText: "",
          labelStyle: TextStyle(fontSize: 15.0),
          hintText: " ",
        ),
      ),
    ),
  ),
)

IOS模拟器中的截图代码

标签: flutterdart

解决方案


你可以试试这个。

Padding(
  padding: EdgeInsets.all(8.0),
  child: Container(
    width: 400,
    height: 120,
    child: Form(
      autovalidate: true,
      child: TextFormField(
        autofocus: true,
        validator: (val) {
          if (val.trim().length > 200)
            return "Beschrijving te lang";
          else
            return null;
        },
        maxLines: 100,
        decoration: InputDecoration(
          border: OutlineInputBorder(),
          filled: true,
          fillColor: Colors.white,
          labelText: "",
          labelStyle: TextStyle(fontSize: 15.0),
          hintText: "Enter a message",
        ),
      ),
    ),
  ),
)

输出:

在此处输入图像描述

在此处输入图像描述


推荐阅读