toTextField method

Widget toTextField(
  1. BuildContext ctx, {
  2. double? width,
  3. double? height,
  4. FocusNode? focusNode,
  5. ValueChanged<String>? onChanged,
  6. VoidCallback? onCompleted,
  7. TextEditingController? controller,
  8. String? hintText,
  9. String? errorText,
  10. bool? enable,
  11. bool? password,
  12. TextInputAction? inputAction,
  13. TextInputType? keyboardType,
  14. TextAlign? textAlign,
  15. int? minLines,
  16. int? maxLines,
  17. double? textSize,
  18. FontWeight? textWeight,
  19. Color? textColor,
  20. Color? hintColor,
  21. BoxConstraints? prefixConstraints,
  22. BoxConstraints? suffixConstraints,
  23. Widget? prefixIcon,
  24. Widget? suffixIcon,
  25. Color? fillColor,
  26. Color? borderColor,
  27. double? borderRadius,
  28. EdgeInsets? contentPadding,
  29. bool? filled,
  30. List<TextInputFormatter>? inputFormatter,
  31. 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),
    // ],
  ]);
}