keditTextPwd function

Widget keditTextPwd({
  1. int? height,
  2. EdgeInsetsGeometry? margin,
  3. EdgeInsetsGeometry? padding,
  4. Color? backgroundColor,
  5. Color? focusBorderColor,
  6. int? focusBorderWidth,
  7. int radius = 0,
  8. TextEditingController? editingController,
  9. TextStyle? textStyle,
  10. String? hint,
  11. TextStyle? hintStyle,
  12. Widget? leftIcon,
  13. Rx<bool>? isfocus,
  14. dynamic onChanged(
    1. String?
    )?,
  15. TextInputType? textInputType,
  16. Rx<bool>? showPassword,
  17. Color? eyeColors,
})

输入框-带显示和隐藏密码 height 高度 margin 外边距 padding 内边距 backgroundColor 背景色 focusBorderColor 获取焦点边框颜色 focusBorderWidth 边框宽度 radius 背景圆角 editingController textStyle 输入文案样式 hint 提示文案 hintStyle 提示文案样式 leftIcon 左侧图片 isfocus 是否获取焦点 onChanged 内容变化监听 textInputType 输入类型 showPassword 是否显示秘密 eyeColors 密码图标颜色

Implementation

Widget keditTextPwd({
  int? height,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  Color? backgroundColor,
  Color? focusBorderColor,
  int? focusBorderWidth,
  int radius = 0,
  TextEditingController? editingController,
  TextStyle? textStyle,
  String? hint,
  TextStyle? hintStyle,
  Widget? leftIcon,
  Rx<bool>? isfocus,
  Function(String?)? onChanged,
  TextInputType? textInputType,
  Rx<bool>? showPassword,
  Color? eyeColors,
}) {
  showPassword = showPassword ?? Rx(false);
  return Container(
    alignment: Alignment.center,
    margin: margin,
    padding: padding,
    decoration: BoxDecoration(
      color: backgroundColor ?? Colors.transparent,
      borderRadius: BorderRadius.circular(radius.r),
      border: isfocus?.value == true
          ? Border.all(
              color:
                  focusBorderColor ?? (backgroundColor ?? Colors.transparent),
              width: focusBorderWidth?.w ?? 1.0,
            )
          : Border.all(
              color: backgroundColor ?? Colors.transparent,
              width: focusBorderWidth?.w ?? 1.0,
            ),
    ),
    height: height?.h,
    child: Stack(
      alignment: AlignmentDirectional.center,
      children: [
        EditText(
          autofocus: isfocus?.value ?? false,
          keyboardType: textInputType,
          textStyle: textStyle,
          focusChanged: (hasFocus) {
            isfocus?.value = hasFocus;
          },
          obscureText: showPassword.value,
          editingController: editingController,
          onChanged: (value) {
            onChanged?.call(value);
          },
          decoration: InputDecoration(
              icon: leftIcon,
              contentPadding: EdgeInsets.only(
                  left: leftIcon == null ? 16.w : -10.w, right: 16.w),
              border: const OutlineInputBorder(borderSide: BorderSide.none),
              hintText: hint,
              hintStyle: hintStyle),
        ),
        Flex(
          direction: Axis.horizontal,
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            Icon(
              showPassword.value ? Icons.visibility : Icons.visibility_off,
              color: eyeColors,
            ).konClickFast(() {
              showPassword?.value = !showPassword.value;
            }),
            SizedBox(width: 0.w, height: 1),
          ],
        ),
      ],
    ),
  );
}