I want to make the hint text to appear inside the textformfield when in focus, rather than at the top edge.
Currently it looks like this Image of textformfield with labeltext sitting at the edge when in focus
But I want the labeltext to appear inside the textformfield
Image of textformfield with labeltext inside the field when in focus
@override Widget build(BuildContext context) {
final InputDecorationTheme inputTheme = Theme.of(context).inputDecorationTheme;
return TextFormField(
enabled: enabled,
key: this.customKey,
controller: textEditingController,
initialValue: initialValue,
inputFormatters: isNumericalOnly
? [
FilteringTextInputFormatter.digitsOnly,
FilteringTextInputFormatter.singleLineFormatter,
]
: [
FilteringTextInputFormatter.singleLineFormatter,
],
keyboardType: isNumericalOnly ? TextInputType.number : TextInputType.text,
focusNode: focusNodeToggle,
maxLength: maxLength,
validator: (String? value) {
return validator != null ? validator!(value.toString()) : null;
},
onSaved: (String? value) {
return onSaved != null ? onSaved!(value.toString()) : null;
},
onChanged: (String? value) {
return onChanged != null ? onChanged!(value.toString()) : null;
},
buildCounter: maxLength != null && isCounterVisible == true
? (BuildContext context, {int? currentLength, int? maxLength, bool? isFocused}) =>
Container(child: Text('$currentLength/$maxLength'))
: (BuildContext context, {int? currentLength, int? maxLength, bool? isFocused}) => null,
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.auto,
hintText: customHintText,
helperText: customHelperText,
helperMaxLines: 2,
border: inputTheme.border,
focusedBorder: inputTheme.focusedBorder,
filled: inputTheme.filled,
fillColor: inputTheme.fillColor,
labelStyle: inputTheme.labelStyle,
label: Text.rich(
TextSpan(
children: <InlineSpan>[
WidgetSpan(
child: Text(
label.toString(),
),
),
WidgetSpan(
child: isDataloading
? LoadingIndicator(
width: 15,
height: 15,
)
: Text('')),
],
),
),
),
); here
