formatEditUpdate method

  1. @override
TextEditingValue formatEditUpdate(
  1. TextEditingValue oldValue,
  2. TextEditingValue newValue
)

Implementation

@override
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
  if (oldValue.text == newValue.text) {
    return newValue;
  }

  var x = super.formatEditUpdate(oldValue, newValue);

  if (x.text.length > this.digitLimit) {
    x = super.formatEditUpdate(oldValue, oldValue);

    if (x.text.isEmpty) {
      x = super.formatEditUpdate(oldValue, newValue);

      x = x.copyWith(text: x.text.substring(0, this.digitLimit));
    }
  }

  return _format(oldValue, x);
}