2

sorry I am new in Flutter. I have tried to find it in Stackoverflow but I can't find it.

I need to make something like this

enter image description here

something like a box that has fix height and width with a multiline input and also scrollable. in native iOS, I can easily use TextView, but I don't know the equivalent for Flutter.

I have tried to make it by using Textfield like this

   TextFormField(
      autofocus: true,
      autocorrect: false,
      keyboardType: TextInputType.multiline,
      maxLines: null,
      decoration: InputDecoration(
        filled: true,
        fillColor: Color(0xFFF2F2F2),
        border: OutlineInputBorder(
          borderRadius: BorderRadius.all(Radius.circular(4)),
          borderSide: BorderSide(width: 1),
        ),
      ),
    ),

but it doesn't have scrolling ability and I can't set the fix height. please help ...

Alexa289
  • 8,089
  • 10
  • 74
  • 178

1 Answers1

2

you just need to set minLines and maxLines shown below, For the box, maxLines do the works for you to set height, And for width, you can wrap TextFormField into a container and gave it manually width.

TextFormField(
  autofocus: true,
  autocorrect: false,
  keyboardType: TextInputType.multiline,
  minLines: 1,
  maxLines: 8,
  decoration: InputDecoration(
    filled: true,
    fillColor: Color(0xFFF2F2F2),
    border: OutlineInputBorder(
      borderRadius: BorderRadius.all(Radius.circular(4)),
      borderSide: BorderSide(width: 1),
    ),
  ),
),
Tushar Patel
  • 500
  • 3
  • 10
  • 1
    this is correct, and to add scrollbar inside a textfield, just add the scrollbar like the answer in here: https://stackoverflow.com/a/48321648/9101876 – Alexa289 Jun 18 '21 at 01:00