androidTextField function
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,
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,
),
),
),
);
}