Vertically bottom Align Text in TextFormField Flutter - flutter

So I know that you can Align the contents in a textformfield through the
textAlignVertical
property. I tried this on my TextFormField:
TextFormField(
textAlignVertical: TextAlignVertical.bottom,
style: TextStyle(
color:
isUnlocked ? Color(0xffF6CD9D) : Colors.grey),
cursorColor: Color(0xffF6CD9D),
enabled: isUnlocked,
controller: vornameController,
decoration: new InputDecoration(
focusColor: Color(0xffF6CD9D),
hoverColor: Color(0xffF6CD9D),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xffF6CD9D)),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xffF6CD9D)),
),
),
),
The result looks like this:
But I want the text to be on the line itself. How can I achieve this behaviour?

Add is dense true and content padding
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.all(0),
...
),

Related

How to remove error space under TextFormField Flutter?

I created TextFormField inside a Container and tried to hide an error line from TextFormField, but it's not working. Is there any way to delete it?
My TextFormField
Code
This is what you need:
the border color for errorBorder & focusedErrorBorder could be changed.
TextField(
keyboardType: TextInputType.emailAddress,
textAlign: TextAlign.center,
onChanged: (value) {
//Do something with the user input.
},
decoration: InputDecoration(
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white, width: 0.0),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue, width: 0.0),
)),),

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

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?
use maxlines properties and remove height from hintstyle
Output :-
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),
),
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->
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),
),
),
),

How to hide the bottom edge on TextField?

How to hide the bottom edge on TextField?
TextField(
decoration: InputDecoration(
hintText: '(201) 555-0123',
),
You can use the *border parameters of TextField:
TextField(
decoration: InputDecoration(
hintText: '(201) 555-0123',
// Hides the border when the TextField is enabled
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Colors.transparent),
),
// Hides the border when you click the TextField
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Colors.transparent),
),
// Hides the border when the TextField is disabled
disabledBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Colors.transparent),
),
),
)
How are you?
You can set the border of InputDecoration to InputBorder.none.
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: S.of(context).textHere,
hintStyle: TextStyle(fontSize: 12),
),
minLines: 5,
maxLines: null,
controller: _content,
keyboardType: TextInputType.multiline,
textCapitalization: TextCapitalization.sentences,
),
https://i.stack.imgur.com/trK69.png

How to change the inside color of a Textfield in flutter?

I want to change the Color of an textfield in flutter.
Means the area within the InputBorder.
I tried to wrap the textfield in container, and change the color of the container, but this seems a fool's step to solve the problem.
I tried the fillColor option, but nothing changed.
Here is my Code -->
Container(
padding: EdgeInsets.fromLTRB(
10,
screenHeight * 0.016415869,
10,
0,
),
height: screenHeight * 0.082079343,
child: TextField(
cursorColor: Color(0xFF7675E0),
textAlign: TextAlign.left,
decoration: InputDecoration(
fillColor: Colors.black, //Nothing Worked
contentPadding: EdgeInsets.fromLTRB(
15,
screenHeight * 0.002735978,
2,
screenHeight * 0.002735978,
),
hintText: "Search",
hintStyle: GoogleFonts.sniglet(
fontSize: screenHeight * 0.020519836,
color: Color(0xFFC6C8CA),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(
color: Colors.grey[200].withOpacity(0.2),
),
),
prefixIcon: Icon(Icons.search),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey[200].withOpacity(1),
),
),
),
),
),
Thanks in Advance :)
Try out this:-
decoration: InputDecoration(
filled: true,
fillColor: Colors.grey,
If you want to set the color to your text field then there is one boolean variable which you need to set true so your color will be added to your text field
Container(
child: TextField(
cursorColor: Color(0xFF7675E0),
textAlign: TextAlign.left,
decoration: InputDecoration(
fillColor: Colors.black, // you can change color of textfield
filled: true, // this should be true if you want to set color to textfield
hintText: "Search",
prefixIcon: Icon(Icons.search),
),
),
),
Basically you can leave your code as you provided us. The important missing value is
filled: true
With this value applied you can style the background color easy.
Reference to the doc: https://api.flutter.dev/flutter/material/TextField-class.html
don't use Container for TextField decoration, there are more property into TextField
TextField use
decoration: InputDecoration(
filled: true,
fillColor: Colors.white10,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.all(
new Radius.circular(14.0),
),
),
TextField(
controller: usernameController,
keyboardType: TextInputType.emailAddress,
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white10,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.all(
new Radius.circular(14.0),
),
),
hintText: 'Username',
hintStyle: TextStyle(color: Colors.white),
contentPadding: const EdgeInsets.all(24),
prefixIcon: Icon(Icons.person, color: Colors.white),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white10),
borderRadius: BorderRadius.circular(14),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white10),
borderRadius: BorderRadius.circular(14),
),
),
),

How to align both the Text and the labelText in the TextFormField in center vertically and without affecting the border?

If you notice the below image, both the label and the text is aligned to top.
Can any one help with what has to be done to make the alignment to centre these two vertically?
Also if you notice just above the 'Email' the border is cut. Could some one help with code snippet to avoid this?
Also is there any way, can we format based on the content(value) of the 'TextFormField'?
The following are the coding which produces the above images.
TextFormField(
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.all(10.0),
labelText: 'Email:',
labelStyle: TextStyle(color: Colors.red, height: 3),
prefixIcon: Icon(Icons.email_outlined),
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.white, width: 1.0)),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.red, width: 2.0)),
prefixStyle: TextStyle(
inherit: true,
color: Colors.red,
),
),
Ideally I wanted a text box like the below one
Flutter allows two types of Edit Input.
Filled Text Field (if the border uses UnderlineInputBorder)
Outlined Text Field (if the border uses OutlineInputBorder)
The following code snippet helped me to fix the issue.
Container(
padding: EdgeInsets.zero,
decoration: BoxDecoration(border: Border.all()),
child: TextFormField(
decoration: const InputDecoration(
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.all(10.0),
labelText: 'Email:',
labelStyle: TextStyle(color: Colors.red, height: 1),
prefixIcon: Icon(Icons.email_outlined),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.transparent)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.transparent)),
prefixStyle: TextStyle(
inherit: true,
color: Colors.red,
),
),
),
)
Your code is ok just remove the "height" parameter from labelStyle
labelStyle: TextStyle(color: Colors.red),