I want to create a Textformfield. But the label shows under the Textformfield, not the border. And Textformfield corner is rounded and the validation error is below the Textformfield.
How to create under the label in Textformfield, not a border, in Flutter
22 Views Asked by Manish sahu At
2
There are 2 best solutions below
0
On
Here is Code that you need:
TextField(
decoration: InputDecoration(
fillColor: Colors.amber,
filled: true,
label: const Text(
'Email',
style: TextStyle(fontSize: 20, color: Colors.black),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
And for the showing error under textfield, simply use
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(40),
borderSide: BorderSide(color: Colors.red, width: 5)),
For more info and details about flutter textfields, visit this article.
Happy Coding :)

Create your own CustomTextField like this: put error text under TextFormField