inputStringCheck static method
InputStatus
inputStringCheck(
- TextEditingController controller,
- String inputValue, {
- bool canInputPoint = false,
- int? maxLength,
处理字符串的输入校验
Implementation
static InputStatus inputStringCheck(TextEditingController controller, String inputValue,
{bool canInputPoint = false, int? maxLength}) {
if (inputValue == '.' && !canInputPoint) {
return InputStatus.FAILURE;
}
if (maxLength != null && controller.text.length >= maxLength) {
return InputStatus.INPUTOUTMAX;
}
controller.text = "${controller.text}$inputValue";
controller.selection = TextSelection.fromPosition(TextPosition(offset: controller.text.length));
return InputStatus.SUCCESS;
}