updateMask method

TextEditingValue updateMask({
  1. String? mask,
  2. Map<String, RegExp>? filter,
  3. MaskAutoCompletionType? type,
  4. TextEditingValue? newValue,
})

Change the mask

Implementation

TextEditingValue updateMask({ String? mask, Map<String, RegExp>? filter, MaskAutoCompletionType? type, TextEditingValue? newValue}) {
  _mask = mask;
  if (filter != null) {
    _updateFilter(filter);
  }
  if (type != null) {
    _type = type;
  }
  _calcMaskLength();
  TextEditingValue? targetValue = newValue;
  if (targetValue == null) {
    final unmaskedText = getUnmaskedText();
    targetValue = TextEditingValue(text: unmaskedText, selection: TextSelection.collapsed(offset: unmaskedText.length));
  }
  clear();
  return formatEditUpdate(TextEditingValue.empty, targetValue);
}