buildMainFormTextField method

Widget buildMainFormTextField({
  1. required FieldData fieldData,
  2. bool isEnable = true,
  3. bool obscureText = false,
  4. String? value,
  5. FormFieldValidator<String>? validator,
  6. dynamic onChange(
    1. String value
    )?,
  7. TextInputAction? textInputAction,
  8. TextInputType? textInputType,
  9. int? maxLength,
  10. Function? onPressSuffixIcon,
  11. dynamic onPress()?,
  12. TextEditingController? controller,
  13. List<TextInputFormatter>? formatters,
})

Implementation

Widget buildMainFormTextField({
  required FieldData fieldData,
  bool isEnable = true,
  bool obscureText = false,
  String? value,
  FormFieldValidator<String>? validator,
  Function(String value)? onChange,
  TextInputAction? textInputAction,
  TextInputType? textInputType,
  int? maxLength,
  Function? onPressSuffixIcon,
  Function()? onPress,
  TextEditingController? controller,
  List<TextInputFormatter>? formatters,
}) {
  return SizedBox(
    child: InkWell(
      onTap: onPress,
      child: AppTextField(
        margin: EdgeInsetsDirectional.symmetric(
            horizontal: 10.sp, vertical: 5.sp),
        formatters: formatters,
        initialValue: value,
        maxLines: 1,
        maxLength: maxLength,
        onChanged: onChange,
        obscureText: obscureText,
        textDirection: textDirection,
        controller: controller,
        labelKey: fieldData.lable,
        enabled: isEnable,
        hintKey: fieldData.hint,
        fillColor: Colors.transparent,
        // focusNode: fieldData.focusNode,
        labelTextStyle: TextStyle(
          fontFamily: FontFamily().normalFont,
          color: AppColors.primary.withOpacity(0.5),
          fontSize: 12.sp,
        ),
        validator: validator,
        textInputAction: textInputAction ?? TextInputAction.next,
        textInputType: textInputType ?? TextInputType.text,
        prefixIcon: Padding(
          padding: EdgeInsetsDirectional.all(5.sp),
          child: SizedBox(
              width: 20.sp,
              height: 20.sp,
              child: SvgPicture.asset(
                fieldData.prefixIconPath,
                package: 'cowpay',
              )),
        ),

        suffixIcon:
            (fieldData.suffixIconPath != null && onPressSuffixIcon != null)
                ? InkWell(
                    onTap: () {
                      onPressSuffixIcon();
                    },
                    child: Padding(
                      padding: EdgeInsetsDirectional.only(
                          start: 10.sp,
                          end: 15.sp,
                          top: 18.sp,
                          bottom: 10.sp),
                      child: SizedBox(
                        width: 20.sp,
                        height: 20.sp,
                        child: SvgPicture.asset(
                          fieldData.suffixIconPath!,
                          package: 'cowpay',
                        ),
                      ),
                    ),
                  )
                : null,
      ),
    ),
  );
}