I am observing that the text for the below form field somehow padded up. Also the cursor has become very small like a dot. Any ideas ?
I want the text field height same as the right side round button
final border = OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent,
),
borderRadius: const BorderRadius.all(
const Radius.circular(
10.0,
),
),
);
return TextFormField(
controller: controller,
onChanged: onChanged,
validator: validator,
autovalidateMode: AutovalidateMode.onUserInteraction,
cursorColor: Theme.of(context).highlightColor,
style: GoogleFonts.poppins(
color: Theme.of(context).highlightColor,
fontSize: 16,
fontWeight: FontWeight.w300,
height: 0.1,
),
textInputAction: TextInputAction.done,
decoration: InputDecoration(
fillColor: Theme.of(context).primaryColorLight,
filled: true,
enabledBorder: border,
focusedBorder: border,
border: border,
labelText: labelText,
// remove label while in focus
floatingLabelBehavior: FloatingLabelBehavior.never,
labelStyle: GoogleFonts.poppins(
color: Theme.of(context).highlightColor,
fontSize: 15,
fontWeight: FontWeight.w300,
),
),
);
The reason for for the additional padding and the small cursor is the font height which you are setting to 0.1 (keep the default 1.0 if you don't want the additional padding).
You can fix the cursor issue by setting cursorHeight to match your original font size
Note: use cursorHeight only if you want to keep the height as 0.1
Related
the labeltext field I set for AutoSizeTextField is insufficient. Is there a way to do multiline?
AutoSizeTextField(
...
style: TextStyle(
fontSize: 22, color: Colors.black),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
labelText: AppLocalizations.of(context)
.translate('total_spent'),
labelStyle: TextStyle(
fontSize: 22, color: Colors.black,),
hintText: spent.toString(),
contentPadding: const EdgeInsets.all(10.0),
...
labelText size depends on AutoSizeTextField's font size if we don't specify the font size on labelStyle.
You can solve it by reducing the fontSize on labelStyle or separate the hit text using \n, label\ntext.
Or providing enough width to AutoSizeTextField.
I have a big problem with DateTimeFormField on Flutter. I can't change hint, label, or default text style color change.
I already try this;
var textStyle = TextStyle(
color: Hexcolor("#D8D8D8"),
fontSize: ScreenUtil().setSp(42.0),
);
return DateTimeFormField(
mode: widget.mode,
label: widget.label,
decoration: InputDecoration(
filled: true,
fillColor: Hexcolor("#F9F9F9"),
contentPadding: EdgeInsets.only(
left: 20.0,
top: 20.0,
bottom: 5.0,
),
prefixStyle: textStyle,
hintStyle: textStyle,
labelStyle: textStyle,
border: defaultBorder,
focusedBorder: focusedBorder,
enabledBorder: enabledBorder,
),
onDateSelected: widget.onDateSelected,
//controller: widget.controller,
//maxLines: maxLines,
//obscureText: obscureText,
);
But color looks like this image :
How can I change the field default color?
Never used the Hexcolor plugin, why don't you try with a basic Color like:
Colors.lightBlue
And then maybe other method with Hexa:
Color(0xFF8BC34A)
When using TextFormField in Flutter and having the form prefilled with text, when I tap somewhere on it in order to start editing the text, I get the little rain drop pointer right over the text:
I expect it to appear a little bit below the form. Something like this:
Here is the code:
Container(
height: 40.0,
child: TextFormField(
style: TextStyle(
fontSize: 17,
),
controller: serverAddressController,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: new BorderRadius.circular(10.0),
),
),
onChanged: (value) {
serverAddress = value;
changesSaved = false;
},
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(daysBackFocusNode);
},
),
),
How do I do it?
you've set Container height to low but didn't reduce content paddings
just add contentPadding property
decoration: InputDecoration(
contentPadding: EdgeInsets.only(left: 16, right: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
I have the following inputfield
child: TextFormField
(
decoration: InputDecoration
(
hintText: 'Enter your name',
labelStyle: Theme.of(context).textTheme.body1,
hintStyle: Theme.of(context).textTheme.body1,
helperStyle: Theme.of(context).textTheme.body1,
prefixStyle: Theme.of(context).textTheme.body1,
counterStyle: Theme.of(context).textTheme.body1,
suffixStyle: Theme.of(context).textTheme.body1,
errorStyle: Theme.of(context).textTheme.body1,
border: OutlineInputBorder
(
borderSide: BorderSide
(
color: Theme.of(context).primaryColor,
width: 2.0,
),
),
enabledBorder: OutlineInputBorder
(
borderSide: BorderSide
(
color: Theme.of(context).primaryColor,
width: 2.0,
),
)
),
validator: (value) {
return value.isEmpty ? 'Please enter your name' : null;
},
),
When I render it it's height is way to big.
The I noticed that when I type something the text is huge
I tried changing all he styles but nothing helps. How can I that text smaller?
Change the font size of TextFormField, not the decoration:
TextFormField(
style: TextStyle(fontSize: 8), // set your font size here
decoration: InputDecoration
( ...
PS
'body1' is deprecated and shouldn't be used. This is the term used in
the 2014 version of material design. The modern term is bodyText2.
This feature was deprecated after v1.13.8
Here is the code:
TextField(
controller: _textEditingController,
decoration: new InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).accentColor,
width: 4.0,
),
borderRadius: new BorderRadius.circular(8.0)),
focusedBorder: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(8.0),
borderSide: new BorderSide(
style: BorderStyle.solid,
color: Theme.of(context).accentColor,
width: 4.0,
),
),
filled: true,
fillColor: _getFillColorBasedOnInput(context),
suffixIcon: IconButton(
icon: SvgPicture.asset(
'assets/images/checkmark_yellow.svg',
color: _textEditingController.text.isEmpty ? Colors.black12 : null,
width: 32.0,
height: 32.0,
)),
),
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.sentences,
textAlign: TextAlign.center,
cursorColor: Theme.of(context).accentColor,
style: new TextStyle(
fontSize: 24,
color: Theme.of(context).accentColor,
))
Here is how it looks like:
Can anyone suggest some solutions to center cursor against the beginning of an input field and a checkmark icon (see red dotted line). I have tried a lot of ideas but none of them led to the desired result. Thank you.
There's 2 things that you can do here:
1) Change the code of the suffix icon in the flutter files by removing the extra padding.
2) This is a workaround, you can use Stack Widget to keep your icon above the Textfield. This way you'll have the cursor centred.
Although, it will look unpleasant if your typed text is too long (i.e. Your typed input below icon). In that case you might limit your lnput.