buildMaskTokens method

void buildMaskTokens(
  1. dynamic masks
)

the BuildMaskTokens will transform the String pattern in tokens to be used as formatter. The mask should a String following the pattern:

9 - is used to allow a number from 0-9

A - is used to allow a letter from a-z or A-Z

N - is used to allow a number or letter from 0-9, a-z or A-Z

X - is used to allow any character

Those tokens 9,A,N and X can be followed by one following modifier

? - indicates that is optional

+ - indicates that must have at least 1 or more repetitions (use as last character)

* - indicates that can have 0 or more repetitions (use as last character)

\ - is used as scape

** Any character that is interpreted as letter to be placed, can be followed by modifier **

! - Used to force print it, when it has at least 1 letter

Implementation

void buildMaskTokens(dynamic masks) {
  List<String> maskList = [];
  if (masks is String) {
    maskList.add(masks);
  } else if (masks is List<String>) {
    maskList = masks;
  } else {
    throw Exception('Unknown mask type');
  }
  _curTag = 0;
  for (var mask in maskList) {
    _allTags.add([]);
    _tags = _allTags[_curTag];
    _processMask(mask);
    _curTag += 1;
  }

  _allTags.sort((maskA, maskB) => maskA.length > maskB.length
      ? 1
      : maskA.length == maskB.length
          ? 0
          : -1);
}