Underline multiple lines in single TextField - Flutter/Dart - flutter

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.

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

Error message showing inside the text form field in Flutter

I have implemented a text form field with validation, and it returns the error message but it gets displayed inside the text form field. Is there a way to show it outside the text form field?
Container(
alignment: Alignment.center,
margin: const EdgeInsets.symmetric(
horizontal: 20),
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.1),
borderRadius: const BorderRadius.all(
Radius.circular(10))),
child: TextFormField(
autovalidateMode:
AutovalidateMode.onUserInteraction,
controller: _controller,
validator: validatePhone,
textAlignVertical: TextAlignVertical.center,
style: const TextStyle(
color: primaryText,
fontFamily: 'InterMedium',
fontSize: 15),
decoration: const InputDecoration(
counterText: '',
errorStyle: TextStyle(
fontFamily: 'InterMedium',
),
prefixIcon: Padding(
padding: EdgeInsets.only(
left: 20, right: 15),
child: Icon(
Icons.phone_android_rounded,
color: secondaryText,
),
),
hintText: 'Enter mobile number',
hintStyle: TextStyle(
fontFamily: 'InterMedium',
color: secondaryText,
),
border: InputBorder.none,
),
cursorColor: secondaryColor,
maxLines: 1,
maxLength: 10,
keyboardType: TextInputType.phone,
textInputAction: TextInputAction.done,
),
),
How it is now -
How I want it to look like -
Remove parent widget Container and add decoration property of TextFormField like below example !
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
cursorColor: Colors.black,
validator: validator,
controller: controller,
keyboardType: TextInputType.phone,
style: const TextStyle(fontSize: 16, color: Colors.black, fontFamily: 'Helvetica', fontWeight: FontWeight.normal),
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xff13367A)),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xff13367A)),
),
border: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xff13367A)),
),
hintText: hint)),
),
P.S :- If you want to add grey color in your TextFormField then you may use decoration: InputDecoration(fillColor: Colors.grey, filled: true) !

How to position the labelText inside a textfield?

I would like to move the label text to the topLeft position.
From this, to this.
Code:
Container buildPendingPageTextField() {
return Container(
alignment: Alignment.topLeft,
width: MediaQuery.of(context).size.width,
child: TextField(
textAlign: TextAlign.start,
controller: attendanceBloc.refusedReasonController,
textInputAction: TextInputAction.done,
maxLines: 3,
minLines: 3,
scrollPhysics: ScrollPhysics(),
style: TextStyle(
height: 1,
fontSize: 15,
letterSpacing: -0.5,
),
decoration: InputDecoration(
errorText: attendanceBloc.error.value,
floatingLabelBehavior: FloatingLabelBehavior.never,
labelText: "Descreva aqui o motivo",
labelStyle: TextStyle(),
border: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
width: 0.3,
),
),
),
),
);
}
I have tried aligment on the container. on the inputDecoration, and even on textStyle, no success.
alignLabelWithHint property
Typically set to true when the InputDecorator contains a multiline TextField (TextField.maxLines is null or > 1) to override the default behavior of aligning the label with the center of the TextField.
You should set alignLabelWithHint to true to override the default behavior of aligning the label with the center:
decoration: InputDecoration(
errorText: attendanceBloc.error.value,
floatingLabelBehavior: FloatingLabelBehavior.never,
labelText: "Descreva aqui o motivo",
labelStyle: TextStyle(),
alignLabelWithHint: true, // Insert this line
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
width: 0.3,
),
),
),
lableText shouldn't be used for such a situation,
instead, use hintText to do it with less code
decoration: InputDecoration(
hintText: 'Descreva aqui o motivo',
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
width: 0.3,
),
),
),

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.
:)

How make text label same size as text size

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().