jared-nelsen
jared-nelsen

Reputation: 1231

Change Size And Behavior of Text Field

I am working to build a screen in my app with several text fields in it. I wish the user to be able to enter a large amount of text in each of them.

There are two problems:

  1. The standard TextField widget is only one line high. I would like it to be many lines high so the user can see all that they have typed.
  2. The standard TextField's behavior seems to act like a typwriter, where the text scrolls infinitely from right to left as the user types. I would like the text to wrap when it hits the edge of the screen.

In short, what I am looking for is your standarrd issue text entry box just like you would be typing into if you were asking a question here.

How do I go about implementing one in Flutter?

Upvotes: 0

Views: 71

Answers (2)

Kalpesh Khandla
Kalpesh Khandla

Reputation: 746

Try with below code snippet

TextFormField(
 maxLines: null,
 expands: true,
 keyboardType: TextInputType.multiline,
 decoration: InputDecoration(filled: true, hintText: 'Enter a message'),

), )

Upvotes: 0

Dhrumil Shah - dhuma1981
Dhrumil Shah - dhuma1981

Reputation: 15799

TextField Widget has maxLines property.

You can use it like this.

new TextField(
   maxLines: 5,
   textAlign: TextAlign.left,
   decoration: new InputDecoration(
      hintText: "Enter Something",
   ),
  )

Upvotes: 2

Related Questions