inputStringCheck static method

InputStatus inputStringCheck(
  1. TextEditingController controller,
  2. String inputValue, {
  3. bool canInputPoint = false,
  4. 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;
}