I'm trying to make a TextFormField
that has an unbounded input field, in the sense where if the user hits the enter key the box can be infinitely expanded. However, it seems that the prefixIcon
attribute is wrapped in a Center
, so whenever the user hits Enter the icon is realigned to the center of the text box, making for a particularly weird experience.
I've been trying to keep that icon from moving but nothing seems to work.
This is my form field:
TextFormField(
maxLines: null,
keyboardType: TextInputType.multiline,
style: theme.textTheme.body1,
decoration: InputDecoration(
prefixIcon: Icon(
Icons.description,
color: theme.iconTheme.color,
),
contentPadding: EdgeInsets.all(15.0),
hintText: 'Enter description'
),
)
you can use prefix:
as instead of prefixIcon
.
TextFormField(
maxLines: null,
keyboardType: TextInputType.multiline,
decoration: InputDecoration(
prefix: Icon(Icons.email),
hintText: 'Enter description'),
),
I solved by adding padding to the prefixIcon
prefixIcon: Padding(
padding: const EdgeInsets.only(bottom: 80),
child: Icon(
icon,
color: color,
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With