InputText constructor
InputText({
- Key? key,
- String value = "",
- bool obscureText = false,
- String placeholder = "",
- String validChars = '',
- InputType type = InputType.text,
- bool emptyOnSubmit = false,
- dynamic onChange(
- String,
- dynamic
- dynamic onSubmit(
- String,
- dynamic
- int maxLines = 1,
- Icon? prefixIcon,
- Icon? suffixIcon,
- Color? color,
- Color? placeholderColor,
- TextAlign textAlign = TextAlign.left,
- double? fontSize,
- String? label,
- bool showBorder = false,
- Color? borderColor,
Implementation
InputText({
super.key,
String value = "",
this.obscureText = false,
this.placeholder = "",
this.validChars = '',
this.type = InputType.text,
this.emptyOnSubmit = false,
this.onChange,
this.onSubmit,
this.maxLines = 1,
this.prefixIcon,
this.suffixIcon,
this.color,
this.placeholderColor,
this.textAlign = TextAlign.left,
this.fontSize,
this.label,
this.showBorder = false,
this.borderColor,
}) {
text.value = value;
controller = TextEditingController(text: text.value);
controller.addListener(() {
text.value = controller.text;
if (onChange != null) {
onChange!(text.value, this);
}
});
if (type == InputType.email) {
validChars = 'a-zA-Z0-9@._-';
keyboardType = TextInputType.emailAddress;
} else if (type == InputType.password) {
validChars = '';
obscureText = true;
} else if (type == InputType.number) {
validChars = '0-9';
keyboardType = TextInputType.number;
} else if (type == InputType.phone) {
validChars = '0-9+';
keyboardType = TextInputType.phone;
} else if (type == InputType.url) {
validChars = 'a-zA-Z0-9@._-:/';
keyboardType = TextInputType.url;
} else {
keyboardType = TextInputType.text;
}
showPassword.value = !obscureText;
if (validChars.isEmpty) {
validChars = '.*';
} else {
validChars = '[$validChars]';
}
}