Я пытаюсь сделать мой 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: " ",
        ),
      ),
    ),
  ),
)

screenshot code in IOS simulator

0
Karel Debedts 17 Авг 2019 в 17:50

2 ответа

Лучший ответ

Вы можете попробовать это.

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",
        ),
      ),
    ),
  ),
)

Вывод:

enter image description here

enter image description here

1
CopsOnRoad 17 Авг 2019 в 18:11

В моем случае это, как я решил это. Вы можете опустить keyboardType: TextInputType.multiline,, чтобы можно было перейти к следующей строке. (введите)

 TextFormField(
                  keyboardType: TextInputType.multiline,
                  controller: _description,
                  maxLines: 10,
                  decoration: InputDecoration(
                      hintMaxLines: 10,
                      hintText: "description",
                      labelText: "Description",
                      hintStyle: hintText),
                ),
1
griffins 17 Авг 2019 в 18:05