fix cakepay number textfield (#3221)

This commit is contained in:
Serhii
2026-05-08 21:37:01 +02:00
committed by GitHub
parent 758cb8d8e5
commit 2c245040c0
+17 -2
View File
@@ -133,8 +133,23 @@ class _NumberTextInputFormatter extends TextInputFormatter {
if (const ['-', ''].contains(newValue.text)) return newValue;
final intValue = int.tryParse(newValue.text);
if (intValue == null) return oldValue;
if (intValue < min) return newValue.copyWith(text: min.toString());
if (intValue > max) return newValue.copyWith(text: max.toString());
if (intValue < min) {
final text = min.toString();
return TextEditingValue(
text: text,
selection: TextSelection.collapsed(offset: text.length),
);
}
if (intValue > max) {
final text = max.toString();
return TextEditingValue(
text: text,
selection: TextSelection.collapsed(offset: text.length),
);
}
return newValue.copyWith(text: intValue.toString());
}
}