mask method
Masks a portion of the string with the specified character.
@param upto The number of characters to mask (or leave unmasked if atEnd
is true).
@param mask The character to use for masking. Defaults to '*'.
@param atEnd If true, masks the end of the string; otherwise, masks the beginning.
@return The masked string, or the original string if masking is not possible.
Implementation
String? mask({int upto = 4, String mask = '*', bool atEnd = false}) {
if (length <= 1 || upto < 1 || length < upto) {
return this;
}
return atEnd
? substring(0, length - upto) + mask * upto
: mask * upto + substring(upto);
}