costum3 method

Widget costum3({
  1. String? title,
  2. required Rx<TextEditingController> controller,
  3. bool isPassword = false,
  4. String? placeholder,
  5. Icon? preicon,
  6. IconButton? suffixiconbutton,
  7. TextInputType? type,
  8. dynamic onChanged(
    1. String
    )?,
  9. Function? onTap,
  10. int? maxLength,
  11. int? minLength,
  12. bool? enabled = true,
  13. int? maxLines,
  14. int? minLines = 1,
  15. FocusNode? focusNode,
})

Implementation

Widget costum3({
  String? title,
  required Rx<TextEditingController> controller,
  bool isPassword = false,
  String? placeholder,
  Icon? preicon,
  IconButton? suffixiconbutton,
  TextInputType? type,
  Function(String)? onChanged,
  Function? onTap,
  int? maxLength,
  int? minLength,
  bool? enabled = true,
  int? maxLines,
  int? minLines = 1,
  FocusNode? focusNode,
}) {
  if (minLines != null) {
    maxLines = minLines + 5;
  }

  if (title != null) {
    placeholder = title;
  }

  return Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      Visibility(
        visible: title != null,
        child: Padding(
          padding: const EdgeInsets.all(4.0),
          child: CustomText.costum1(title.toString()),
        ),
      ),
      TextField(
        onTap: () {
          if (onTap == null) {
            return;
          }
          onTap();
        },
        onChanged: (value) {
          // setstate();
          controller.refresh();
          if (onChanged != null) {
            onChanged(value);
          }

          if (!isPassword && maxLength != null) {
            if (value.length >= maxLength) {
              return;
            }
          }
        },
        focusNode: focusNode,
        enabled: enabled,
        controller: controller.value,
        obscureText: isPassword,
        minLines: minLines,
        maxLines: !isPassword ? maxLines : 1,
        maxLength: maxLength,
        keyboardType: type,
        textInputAction: TextInputAction.next,
        autofillHints: const [AutofillHints.username],
        decoration: InputDecoration(
          contentPadding: const EdgeInsets.all(16.0),
          suffixIcon: suffixiconbutton,
          counter: minLength != null || maxLength != null
              ? minLength != null && controller.value.text.length < minLength
                  ? Text(
                      "${controller.value.text.length}/${controller.value.text.length <= minLength ? minLength : minLength}",
                      style: TextStyle(
                        color: controller.value.text.length < minLength
                            ? Colors.red
                            : Colors.grey,
                      ),
                    )
                  : maxLength != null
                      ? Text(
                          "${controller.value.text.length}/${controller.value.text.length >= maxLength ? maxLength : maxLength}",
                          style: TextStyle(
                            color: controller.value.text.length == maxLength
                                ? Colors.red
                                : Colors.grey,
                          ),
                        )
                      : null
              : null,
          border: const OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(10)),
            borderSide: BorderSide.none,
          ),
          prefixIcon: preicon,
          hintText: placeholder,
          filled: true,
        ),
      ),
    ],
  );
}