keditText function
Widget
keditText({
- 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,
- bool isPassword = false,
输入框
height
高度
margin
外边距
padding
内边距
backgroundColor
背景色
focusBorderColor
获取焦点边框颜色
focusBorderWidth
边框宽度
radius
背景圆角
editingController
textStyle
输入文案样式
hint
提示文案
hintStyle
提示文案样式
leftIcon
左侧图片
isfocus
是否获取焦点
onChanged
内容变化监听
textInputType
输入类型
isPassword
是否秘密,现实还是隐藏输入内容
Implementation
Widget keditText({
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,
bool isPassword = 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: EditText(
autofocus: isfocus?.value ?? false,
keyboardType: textInputType,
textStyle: textStyle,
focusChanged: (hasFocus) {
isfocus?.value = hasFocus;
},
obscureText: isPassword,
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),
),
);
}