toTextField method
Widget
toTextField(
- BuildContext ctx, {
- double? width,
- double? height,
- FocusNode? focusNode,
- ValueChanged<
String> ? onChanged, - VoidCallback? onCompleted,
- TextEditingController? controller,
- String? hintText,
- String? errorText,
- bool? enable,
- bool? password,
- TextInputAction? inputAction,
- TextInputType? keyboardType,
- TextAlign? textAlign,
- int? minLines,
- int? maxLines,
- double? textSize,
- FontWeight? textWeight,
- Color? textColor,
- Color? hintColor,
- BoxConstraints? prefixConstraints,
- BoxConstraints? suffixConstraints,
- Widget? prefixIcon,
- Widget? suffixIcon,
- Color? fillColor,
- Color? borderColor,
- double? borderRadius,
- EdgeInsets? contentPadding,
- bool? filled,
- List<
TextInputFormatter> ? inputFormatter, - Key? key,
Implementation
Widget toTextField(
BuildContext ctx, {
double? width,
double? height,
FocusNode? focusNode,
ValueChanged<String>? onChanged,
VoidCallback? onCompleted,
TextEditingController? controller,
String? hintText,
String? errorText,
bool? enable,
bool? password,
TextInputAction? inputAction,
TextInputType? keyboardType,
TextAlign? textAlign,
int? minLines,
int? maxLines,
double? textSize,
FontWeight? textWeight,
Color? textColor,
Color? hintColor,
BoxConstraints? prefixConstraints,
BoxConstraints? suffixConstraints,
Widget? prefixIcon,
Widget? suffixIcon,
Color? fillColor,
Color? borderColor,
double? borderRadius,
EdgeInsets? contentPadding,
bool? filled,
List<TextInputFormatter>? inputFormatter,
Key? key,
}) {
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
width: width,
height: height,
child: TextFormField(
key: key,
enableInteractiveSelection: true,
textAlignVertical: TextAlignVertical.center,
focusNode: focusNode,
onChanged: onChanged,
controller: controller,
initialValue: controller != null ? null : this,
enabled: enable ?? true,
minLines: minLines ?? 1,
maxLines: maxLines ?? 1,
textInputAction: inputAction ?? TextInputAction.done,
keyboardType: keyboardType ?? TextInputType.text,
onEditingComplete: onCompleted,
obscureText: password ?? false,
maxLengthEnforcement: MaxLengthEnforcement.enforced,
style: GlobalConfig.fontFamily
.fsize(textSize ?? 14)
.fweight(textWeight ?? FontWeight.w400)
.fcolor(textColor ?? Colors.black),
textAlign: textAlign ?? TextAlign.left,
inputFormatters: inputFormatter,
decoration: InputDecoration(
prefixIconConstraints: prefixConstraints,
suffixIconConstraints: suffixConstraints,
prefixIcon: prefixIcon,
suffixIcon: suffixIcon,
hintText: hintText,
hintStyle: GlobalConfig.fontFamily
.fsize(textSize ?? 14)
.fweight(textWeight ?? FontWeight.w400)
.fcolor(hintColor ?? Colors.grey),
fillColor: fillColor ?? Colors.white,
filled: filled ?? true,
contentPadding: contentPadding,
border: InputBorder.none,
enabledBorder: InputBorder.none,
// OutlineInputBorder(
// borderSide: BorderSide(color: borderColor ?? ctx.theme.cSecondary, width: 1),
// borderRadius: BorderRadius.circular(borderRadius ?? 8.mb),
// ),
focusedBorder: InputBorder.none,
// OutlineInputBorder(
// borderSide: BorderSide(color: borderColor ?? ctx.theme.cHighlightRed, width: 2.mb),
// borderRadius: BorderRadius.circular(borderRadius ?? 8.mb),
// ),
),
),
),
// if (errorText != null) ...[
// SizedBox(height: 5.mb),
// toTextOneLine(style: ctx.theme.sHighlightRed(12.mb).ellipsis.italic),
// ],
]);
}