Search code examples
androidflutterdarttexttextfield

how to move the label in text field in flutter?


hi i have a text field that is for content . so it should have bigger space.

but my problem is the label - text i used in this text field . is in the center . and i don't like it at all .

i want to be at the start of box :(

like this:

enter image description here

this is my code too:

 TextField(
              maxLines: 10,
              controller: _content,
              decoration: const InputDecoration(
                floatingLabelAlignment: FloatingLabelAlignment.start,
                labelText: 'Content',
                border: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(15))),
              ),

Solution

  • You just need to set alignLabelWithHint to true enter image description here

    TextField(
                  maxLines: 10,
                 
                  decoration: const InputDecoration(
                    floatingLabelAlignment: FloatingLabelAlignment.start,
                    alignLabelWithHint: true,
                    labelText: 'Content',
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(15))),
                  ),)
    

    for more info here