keditTextPwd function
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, - dynamic onChanged()?,
- TextInputType? textInputType,
- Rx<
bool> ? showPassword, - 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),
],
),
],
),
);
}