I need to change the position of the cursor inside the textformfield. I managed to reduce the height of the cursor with 1, but the position of the cursor remains top. I was not be able to move it to the bottom.
I wanted to achieve this:
But what I achieve is:
Is there a way to do it in Flutter?
My code sample
TextFormField(
style: TextStyle(
color: Theme.of(context).textTheme.bodySmall?.color,
fontSize: 14,
),
minLines: 1,
maxLines: 1,
maxLength: 300,
cursorColor: Theme.of(context).hintColor,
textAlignVertical: TextAlignVertical.center,
cursorHeight: 1,
cursorWidth: 15,
);
4
Answers
Add style in your TextFormField
height: 0.1
For CupertinoTextField
TextFormField has the property of
height
inside thestyle
– you can apply 0.0 on height to achieve your output. also frombottom
ortop
padding you can usecontentPadding
so you can apply or remove the padding from top left to bottom right from cursor to input line :I would want to add to rahulVFlutterAndroid’s answer.
Why is this observed?
Because, by default, the cursor starts from left top of the textField. By changing the height of the cursor, the cursor moved to the top left position.
How can we overcome this?
Use height and set it to
0.0
: