androidTextField function

TextFormField androidTextField(
  1. String? hint,
  2. String? label,
  3. String? initialValue,
  4. Color? hintColor,
  5. double? padding,
  6. Color? bgColor,
  7. Color? labelColor,
  8. Color? borderColor,
  9. Color? focusBorderColor,
  10. bool? obscureText,
  11. Function? onChanged,
  12. Widget? suffix,
  13. Widget? prefix,
  14. TextInputType? keyboardType,
  15. TextEditingController? controller,
  16. int? maxLength,
  17. int? maxLines,
  18. bool? readOnly,
  19. TextCapitalization? textCapitalization,
  20. FocusNode? focusNode,
  21. TextAlign? textAlign,
  22. List<TextInputFormatter>? inputFormatters,
  23. Function? onSubmitted,
  24. TextInputAction? textInputAction,
)

Android Text Field

Implementation

TextFormField androidTextField(
  String? hint,
  String? label,
  String? initialValue,
  Color? hintColor,
  double? padding,
  Color? bgColor,
  Color? labelColor,
  Color? borderColor,
  Color? focusBorderColor,
  bool? obscureText,
  Function? onChanged,
  Widget? suffix,
  Widget? prefix,
  TextInputType? keyboardType,
  TextEditingController? controller,
  int? maxLength,
  int? maxLines,
  bool? readOnly,
  TextCapitalization? textCapitalization,
  FocusNode? focusNode,
  TextAlign? textAlign,
  List<TextInputFormatter>? inputFormatters,
  Function? onSubmitted,
  TextInputAction? textInputAction,
) {
  return TextFormField(
    initialValue: initialValue,
    onChanged: onChanged as void Function(String),
    textCapitalization: textCapitalization ?? TextCapitalization.none,
    obscureText: obscureText ?? false,
    keyboardType: keyboardType,
    controller: controller,
    maxLength: maxLength,
    maxLines: maxLines ?? 1,
    readOnly: readOnly ?? false,
    focusNode: focusNode,
    textAlign: textAlign ?? TextAlign.start,
    inputFormatters: inputFormatters,
    onFieldSubmitted: onSubmitted as void Function(String)?,
    textInputAction: textInputAction,
    decoration: InputDecoration(
      fillColor: bgColor ?? Colors.transparent,
      filled: bgColor != null,
      suffixIcon: Padding(
        padding: EdgeInsets.only(right: padding ?? 10.0),
        child: suffix,
      ),
      contentPadding: EdgeInsets.all(padding ?? 10.0),
      hintText: hint,
      labelText: label,
      labelStyle: TextStyle(
        color: labelColor ?? Colors.black,
      ),
      hintStyle: TextStyle(
        color: hintColor ?? Colors.black,
      ),
      enabledBorder: UnderlineInputBorder(
        borderSide: BorderSide(
          color: borderColor ?? Colors.black,
        ),
      ),
      focusedBorder: UnderlineInputBorder(
        borderSide: BorderSide(
          color: focusBorderColor ?? Colors.blue,
        ),
      ),
    ),
  );
}