keyPress method
dynamic
keyPress(
- KeyMode keyMode
)
Implementation
keyPress(KeyMode keyMode) {
InputLimitMode? limitMode = findCurrentFocusMode();
if (limitMode == null) {
return;
}
if (keyMode.inputType == 0) {
InputStatus inputStatus = InputStatus.FAILURE;
if (limitMode.inputType == 0) {
//字符串
inputStatus = CheckInputUtil.inputStringCheck(limitMode.controller, keyMode.title,
canInputPoint: limitMode.enableInputPoint, maxLength: limitMode.maxLength);
} else if (limitMode.inputType == 1) {
//数字
inputStatus = CheckInputUtil.inputNumCheck(limitMode.controller, keyMode.title,
enableInputDecimal: limitMode.enableInputPoint,
maxInput: limitMode.maxInput,
maxLengthInteger: limitMode.maxLength,
maxLengthDecimal: limitMode.maxLengthDecimal);
}
if (inputStatus == InputStatus.SUCCESS) {
streamController?.add(limitMode.controller);
}
} else {
TextEditingController controller = limitMode.controller;
String text = controller.text;
if (text.isNotEmpty) {
controller.text = text.substring(0, text.length - 1);
controller.selection = TextSelection.fromPosition(TextPosition(offset: controller.text.length));
streamController?.add(limitMode.controller);
}
}
}