generateForm method
Implementation
Widget generateForm(BuildContext context, FocusNode currentFocus, OwlnextInputState state) {
return TextFormField(
scrollPhysics: state.widget.physics ?? const BouncingScrollPhysics(),
textInputAction: state.widget.textInputAction,
onFieldSubmitted: (String val) {
if (state.widget.textInputAction != null){
currentFocus.unfocus();
// FocusScope.of(context).requestFocus(nextFocus);
} else if (state.widget.onSubmitted != null) {
state.widget.onSubmitted!(val);
}
},
autovalidateMode: state.hasBeenValidatedOnce ? AutovalidateMode.disabled : AutovalidateMode.disabled, //REVERTED TO DISABLED TO AVOID FOCUS PROBLEM
focusNode: currentFocus,
textAlign: state.widget.textAlign ?? TextAlign.left,
autofillHints: state.widget.autofillHints ?? [],
onEditingComplete: state.widget.onEditingComplete,
enabled: state.widget.enabled,
minLines: state.widget.minimumLines,
maxLines: state.widget.minimumLines,
keyboardType: [TextInputSubType.date, TextInputSubType.shortDate].contains(state.widget.type) ? TextInputType.datetime
: [TextInputSubType.hours, TextInputSubType.numbers, TextInputSubType.amount].contains(state.widget.type) ? TextInputType.number
: null,
inputFormatters: formatter(state),
decoration: state.widget.inputDecoration?.copyWith(
hintText: generateHintText(state),
) ?? Artist().inputDecoration.copyWith(
isDense: true,
hintText: generateHintText(state),
errorText: state.widget.errorText != '' ? state.widget.errorText : null,
fillColor: state.widget.enabled == true ? Artist().filledInputColor : Artist().disabledFilledInputColor,
suffixIcon: state.getSuffixIcon,
suffixText: state.getSuffixIcon != null ? state.widget.suffixText : null,
suffixStyle: Theme.of(context).textTheme.bodySmall?.copyWith(color: Colors.grey,),
prefixIcon: state.widget.prefixIcon,
floatingLabelBehavior: FloatingLabelBehavior.auto,
labelText: Artist().inputDecoration.floatingLabelBehavior == FloatingLabelBehavior.auto ? state.widget.label : null,
floatingLabelStyle: Artist().inputDecoration.floatingLabelBehavior == FloatingLabelBehavior.auto ? Artist().labelTextStyle : null,
// contentPadding: const EdgeInsets.symmetric(horizontal: 10.0),
labelStyle: Artist().inputDecoration.floatingLabelBehavior == FloatingLabelBehavior.auto ? Artist().labelTextStyle : null,
),
style: state.widget.innerInputTextStyle ?? Artist().innerInputTextStyle,
obscureText: state.widget.type == TextInputSubType.password,
controller: state.widget.controller,
initialValue: (Artist().computeTextInputsWhenNull == true && state.widget.controller == null && state.widget.text == null) ? "" : state.widget.text,
onTap: () {
// FocusScope.of(context).requestFocus(FocusNode());
},
onChanged: (value) {
// FocusScope.of(context).requestFocus(FocusNode());
if (state.widget.onChanged != null) {
state.widget.onChanged!(value);
}
},
validator: (String? value) => state.validator(value),
);
}