SmartTextField constructor
SmartTextField({
- Key? key,
- String text = "",
- required String hintText,
- required TextEditingController controller,
- bool singleLine = true,
- TextStyle? titleStyle,
- TextStyle? textStyle,
- TextStyle? hintStyle,
- Color? color,
- Color? borderColor,
- double borderWidth = 1,
- double radius = 10.0,
- dynamic onChanged,
- Color? enabledColor,
- Color? focusedColor,
- String? labelText,
- TextStyle? labelStyle,
- bool isUnderline = true,
- bool expands = false,
- double? width,
- double? height,
- TextInputType textInputType = TextInputType.text,
- Widget? prefixIcon,
- Color? backgroundColor,
- EdgeInsetsGeometry? padding = EdgeInsets.zero,
- EdgeInsetsGeometry? innerPadding,
- bool noInputBorder = false,
- int flex = 1,
Implementation
SmartTextField(
{Key? key,
this.text = "",
required this.hintText,
required this.controller,
this.singleLine = true,
this.titleStyle,
this.textStyle,
this.hintStyle,
this.color,
this.borderColor,
this.borderWidth = 1,
this.radius = 10.0,
this.onChanged,
this.enabledColor,
this.focusedColor,
this.labelText,
this.labelStyle,
this.isUnderline = true,
this.expands = false,
this.width,
this.height,
this.textInputType = TextInputType.text,
this.prefixIcon,
this.backgroundColor,
this.padding = EdgeInsets.zero,
this.innerPadding,
this.noInputBorder = false,
this.flex = 1})
: super(key: key) {
innerPadding ??= EdgeInsets.symmetric(horizontal: 10);
titleStyle ??= Get.find<AppSettings>().anyMobile
? Get.find<AppFonts>().S(fontWeight: FontWeight.w600)
: Get.find<AppFonts>().M(fontWeight: FontWeight.w600);
textStyle ??= Get.find<AppFonts>().M();
labelStyle ??= Get.find<AppFonts>().M();
hintStyle ??=
Get.find<AppFonts>().M(color: Get.find<AppColors>().hintColor);
enabledColor ??= Get.find<AppColors>().textColor;
focusedColor ??= Colors.cyan;
if (!noInputBorder) {
if (isUnderline) {
enabledBorder = UnderlineInputBorder(
borderSide: BorderSide(color: enabledColor!),
);
focusedBorder = UnderlineInputBorder(
borderSide: BorderSide(color: focusedColor!),
);
} else {
enabledBorder = OutlineInputBorder(
borderSide: BorderSide(color: enabledColor!),
borderRadius: BorderRadius.circular(radius));
focusedBorder = OutlineInputBorder(
borderSide: BorderSide(color: focusedColor!),
borderRadius: BorderRadius.circular(radius));
}
}
border = borderColor != null
? Border.all(width: borderWidth, color: borderColor!)
: null;
}