How make text label same size as text size - flutter

I want to make label size same as the text size of textfield. when it is clicked the label is going up and size is decreased.
here are some code that i have tried
child: TextField(
style: TextStyle(fontSize: 12),
obscureText: true,
cursorColor: AppColors.gray,
decoration: InputDecoration(
labelText: "Confirm Password",
labelStyle: TextStyle(
color: AppColors.gray,
fontSize: 12
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: AppColors.gray)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: AppColors.gray)),
contentPadding: EdgeInsets.all(2)),
))

I doubt you can that do that. Perhaps what you want is another Text() above your TextField() inside a Column().

Related

flutter how remove text underline on text selection (TextFormField)?

It is necessary to move the cursor to the end of the text, but in flutter this is strangely implemented through text selection, I do it like this
textController.selection =
TextSelection.collapsed(offset: textController.text.length);
it works, but when typing, it appears underlined
It is possible to somehow remove the underlining of the text, I read the documentation, but did not find it.
My TextFormField
TextFormField(
cursorColor: Colors.white,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
),
controller: textController,
autofocus: false,
decoration: const InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white)),
filled: true,
isDense: true,
hintText:
'search',
hintStyle: TextStyle(
//Style of hintText
color: Colors.white60,
fontSize: 20,
),
),
),
This might help you:
TextField(
style: const TextStyle(
decoration: TextDecoration.none),
),

Vertically bottom Align Text in TextFormField 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),
...
),

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),

Underline multiple lines in single TextField - Flutter/Dart

Looking to have a TextField which has multiple rows but also an underline for each row. When typing text it should continue to the next row without needing the return key.
Current:
TextField(
maxLines: 2,
decoration: InputDecoration(
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1.0,
style: BorderStyle.solid),
),
),
)
Current Output:
Desired Output:
this will work for you I guess
TextField(
keyboardType: TextInputType.multiline,
minLines: 100,
maxLines: 500,
style: TextStyle(
decoration: TextDecoration.underline,
),
decoration: InputDecoration(
enabledBorder: InputBorder.none,
hintText: 'Notes.....',
hintStyle: TextStyle(color: Colors.black87),
),
),
If you'd still like to change the color or type or density of the underline use the decorationStyle,decorationColor, and decorationThickness properties.

How to add underlines to a multiline input in Flutter?

so this displays an underline under a single TextField
TextField(
decoration: InputDecoration(
hintText: 'Notes.....',
hintStyle: TextStyle(color: Colors.black87),
border: new UnderlineInputBorder(
borderSide: BorderSide(color: Colors.black87,
width: 1.0, style: BorderStyle.solid)
But when I do this
TextField(
keyboardType: TextInputType.multiline,
minLines: 100,
masLines: 500,
decoration: InputDecoration(
hintText: 'Notes.....',
hintStyle: TextStyle(color: Colors.black87),
border: new UnderlineInputBorder(
borderSide: BorderSide(color: Colors.black87,
width: 1.0, style: BorderStyle.solid)
It disappears? Is there anyway to have the lines show up?
This will work.
TextField(
keyboardType: TextInputType.multiline,
minLines: 100,
maxLines: 500,
style: TextStyle(
decoration: TextDecoration.underline,
),
decoration: InputDecoration(
enabledBorder: InputBorder.none,
hintText: 'Notes.....',
hintStyle: TextStyle(color: Colors.black87),
),
),
If you'd still like to change the colour or type or density of the underline use the decorationStyle ,decorationColor and decorationThickness properties.
:)