i search some issues on flutter github and stackoverflow to resolve this problem
in below implementation in flutter i can't type Enter to have more line in TextFormField, i think i set correctly keyboardType and maxLines, but my keyboard on phone doesn't have enter key and that's next
TextFormField(
textAlign: TextAlign.start,
keyboardType: TextInputType.multiline,
maxLines: 7,
style: Theme.of(context).textTheme.caption.copyWith(
color: Colors.black,
),
textInputAction: TextInputAction.next,
),
Remove textInputAction: TextInputAction.next
TextFormField(
textAlign: TextAlign.start,
keyboardType: TextInputType.multiline,
maxLines: 7,
style: Theme.of(context).textTheme.caption.copyWith(
color: Colors.black,
),
//textInputAction: TextInputAction.next,
);
or as #Siddharth Patankar commented set textInputAction: TextInputAction.newline
Related
When I select all the text in Textfield there's a line between each lines of text. This line appears when I increase the Textfield fontSize.
Behavior
Expected behavior
Edit
Below is my Textfield code snippet. I made this as re-usable.
TextField(
onTap: onTap,
controller: controller,
focusNode: focusNode,
obscureText: obscureText ?? false,
autofocus: autofocus ?? false,
onChanged: onChanged,
onEditingComplete: onEditingComplete,
onSubmitted: onSubmitted,
scrollPhysics: const BouncingScrollPhysics(),
maxLines: maxLines,
minLines: minLines,
textCapitalization: TextCapitalization.sentences,
textInputAction: textInputAction,
keyboardType: TextInputType.multiline,
selectionWidthStyle: BoxWidthStyle.max,
readOnly: readOnly!,
selectionHeightStyle: BoxHeightStyle.strut,
maxLengthEnforcement: MaxLengthEnforcement.enforced,
style: TextStyle(
fontSize: fontSize,
fontWeight: fontWeight ?? FontWeight.normal,
color: color ?? Theme.of(context).primaryColor,
),
enableInteractiveSelection: true,
decoration: decoration ??
InputDecoration(
isDense: isDense,
border: InputBorder.none,
icon: iconData ?? widgetIcon,
suffix: suffix,
hintText: hintText,
hintStyle: TextStyle(
fontSize: fontSize ?? hintFontSize,
fontWeight: fontWeight ?? FontWeight.normal,
),
),
);
This is a font specific problem with your chosen font size.
For example if you change text style to this:
TextStyle(
fontSize: fontSize,
fontWeight: fontWeight ?? FontWeight.normal,
height: 1.0,
color: color ?? Theme.of(context).primaryColor,
),
You will no longer see the spaces, check the description on height for more details.
TextInputAction.newline does not work on custom keyboards, only on the Google keyboard, when I press the Enter key on custom keyboards, nothing happens.
TextField(
focusNode: focusNode,
textInputAction: TextInputAction.newline,
style: Theme.of(context)
.textTheme
.subtitle1!
.copyWith(fontSize: config.s17),
onChanged: (text) {
feedbackBloc.add(MessageChangedEvent(text));
},
keyboardType: TextInputType.multiline,
maxLines: null,
maxLength: 2000,
buildCounter: (
context, {
required currentLength,
required isFocused,
maxLength,
}) =>
null,
decoration: InputDecoration.collapsed(
hintText: tr('settings.how'),
hintStyle: TextStyle(
color: grayTextColor,
fontSize: config.s17,
fontWeight: FontWeight.w400,
),
),
),
I have code like this
Stack(
children: [
TextFormField(
autofocus: true,
autocorrect: false,
maxLines: 1,
textAlign: TextAlign.center,
),
Positioned(
bottom: 14,
left: 0,
child: Text("Rp"),
),
],
),
I know I can set the text in the center using TextAlign.center, but now I want to make the text inside textfield at the start + around 24 pt from start
I can't use TextAlign.start since it will overlap the 'Rp' text.
how to do that?
Use Prefix or Suffix for the "Rp" text:
TextFormField(
decoration: InputDecoration(
prefix: ...,
suffix: ...,)
Then you can use textAlign
Try below code hope its helpful to you you can use prefix propery inside Inputdecoration of TextFormField here and InputDecoration here
TextFormField(
autofocus: true,
autocorrect: false,
maxLines: 1,
textAlign: TextAlign.center,
decoration: InputDecoration(
prefix: Text('Rp'),
),
),
Your result screen->
TextFormField(
decoration: InputDecoration(
prefixText: 'Rp',
),
),
I'm using a textfield widget:
TextField(
controller: _taskNamecontroller,
focusNode: _focus,
textInputAction: TextInputAction.done,
maxLines: null,
decoration: InputDecoration(
border: InputBorder.none,
hintText: SC.current.taskHeaderTaskName),
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
height: 1.25),
),
and when adding this emoji 1️⃣ from the keyboard, it renders very strangely, it shows the 1 followed by a weird symbol:
Why is Flutter failing to render this emoji appropriately?
use GoogleFonts.notoColorEmojiCompat() for style
How does one underline for each character in Flutter? I want to do phone verification and want each line to hold a single character but don't know how to do it (or if it's even possible) with a single TextForm.
Example:
This is a rephrased version of this question: Connecting multiple text fields to act like a single field in Flutter
Flutter package that handles this: https://pub.dev/packages/pin_code_fields
Use this :
TextField(
obscureText: true,
keyboardType: TextInputType.text,
textAlign: TextAlign.center,
maxLength: 1,
),
Must Add this In your ThemeData:
ThemeData(
primarySwatch: Colors.red,
accentColor: Colors.amber,
For Your Case You Can Dow that
Row(
children<>[
TextField(
obscureText: true,
keyboardType: TextInputType.text,
textAlign: TextAlign.center,
maxLength: 1,
),
TextField(
obscureText: true,
keyboardType: TextInputType.text,
textAlign: TextAlign.center,
maxLength: 1,
),
TextField(
obscureText: true,
keyboardType: TextInputType.text,
textAlign: TextAlign.center,
maxLength: 1,
),
TextField(
obscureText: true,
keyboardType: TextInputType.text,
textAlign: TextAlign.center,
maxLength: 1,
),
TextField(
obscureText: true,
keyboardType: TextInputType.text,
textAlign: TextAlign.center,
maxLength: 1,
),
]
)
For Layout Fixing use Exapand()