updateMask method

void updateMask(
  1. String newMask, {
  2. bool shouldMoveCursorToEnd = true,
  3. bool shouldUpdateValue = false,
})

Replaces mask with a newMask and moves cursor to the end if shouldMoveCursorToEnd is true shouldUpdateValue Set to true to request a following update in the text. If this method is being called in beforeChange this MUST be false, since it will call updateText as next step automatically.

Implementation

void updateMask(
  String newMask, {
  bool shouldMoveCursorToEnd = true,
  bool shouldUpdateValue = false,
}) {
  if (mask != newMask) {
    _previousMask = mask;
    mask = newMask;

    if (shouldUpdateValue) {
      updateText(text);
    }

    if (shouldMoveCursorToEnd) {
      moveCursorToEnd();
    }
  }
}