Home > OS >  set size and position in flutter text field,which is the way
set size and position in flutter text field,which is the way

Time:03-31

enter image description here

SizedBox(
                  width: double.infinity,
                  child: TextField(
                    decoration: InputDecoration(
                        hintStyle: TextStyle(height: 12),
                        isDense: true,
                        hintText: "Buraya yazın...",
                        border: OutlineInputBorder(
                          borderSide: BorderSide.none,
                          borderRadius: BorderRadius.circular(10),
                        ),
                        fillColor: Color(0xFFD8DDE0),
                        filled: true),
                  ),
                ),

how can i make this text field anyone can help me?

I tried to adjust the height of the text, but its position is centered, how can I make this text field this time?

CodePudding user response:

use maxlines properties and remove height from hintstyle

Output :-

enter image description here

Code:-

TextField(
          maxLines: 5,
          decoration: InputDecoration(
              isDense: true,
              hintText: "Buraya yazın...",
              border: OutlineInputBorder(
                borderSide: BorderSide.none,
                borderRadius: BorderRadius.circular(10),
              ),
              fillColor: Color(0xFFD8DDE0),
              filled: true),
        ),

CodePudding user response:

Try below code:

TextField(
      textAlignVertical: TextAlignVertical.top,
      maxLines: 6,
      decoration: InputDecoration(
        isDense: true,
        hintText: "Buraya yazın...",
        border: OutlineInputBorder(
          borderSide: BorderSide.none,
          borderRadius: BorderRadius.circular(10),
        ),
        fillColor: Color(0xFFD8DDE0),
        filled: true,
      ),
    ),

Result Screen->image

CodePudding user response:

Use textAlign to align the text at the start and you can use the maxLines property of TextFormField to adjust its height.

Code Snipped:

TextFormField(
  maxLines: 8,
  textAlign: TextAlign.start,
  decoration: InputDecoration(
     hintText: "Buraya yazın...",
     fillColor: const Color(0xFFD8DDE0),
     filled: true,
     border: OutlineInputBorder(
        borderSide: BorderSide.none,
        borderRadius: BorderRadius.circular(15),
      ),
    ),
  ),
  • Related