I have used TextField
inside Container
with fixed width and height. Once I set container height:40
then TextField
hint text and text are not aligned centerLeft but if I set Container height:50
then all things go fine. I have also tried to set fontSize but still not working. I have checked these are the questions : Question 1 , Question 2, Question 3 and also tried some other code also but won't worked while container height:40
.
This is the Code that I am using :
Container(
width: 300,
height: 40,
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.deepPurpleAccent,
),
child: TextFormField(
textAlign: TextAlign.left,
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(left: 16),
hintText: 'Enter your text',
border: InputBorder.none,
hintStyle: TextStyle(
color: Colors.white,
),
),
),
),
UI(Out Put) when height:50
(perfect):
UI(Out Put) when height:40
(Issue with alignment):
You can use isDense: true
, it will adapt the height.
decoration: InputDecoration(
contentPadding: EdgeInsets.only(left: 16),
hintText: 'Enter your text',
isDense: true,