maskText method
Implementation
Future<String> maskText(String text) async {
final bool? maskingEnabled = await getMaskingEnabled();
if (maskingEnabled!) {
if ((await _TlConfiguration().get(
"GlobalScreenSettings/Masking/HasCustomMask",
) ??
"")
.toString()
.contains("true")) {
final String? smallCase = await _TlConfiguration().get(
"GlobalScreenSettings/Masking/Sensitive/smallCaseAlphabet",
);
final String? capitalCase = await _TlConfiguration().get(
"GlobalScreenSettings/Masking/Sensitive/capitalCaseAlphabet",
);
final String? symbol = await _TlConfiguration().get(
"GlobalScreenSettings/Masking/Sensitive/symbol",
);
final String? number = await _TlConfiguration().get(
"GlobalScreenSettings/Masking/Sensitive/number",
);
// Note: The following r"\p{..} expressions have been flagged erroneously as errors in some versions of the IDE
// However, they work fine and also do NOT show up in linter, so they do not break CI/CD
if (smallCase != null) {
text = text.replaceAll(RegExp(r"\p{Ll}", unicode: true), smallCase);
}
if (capitalCase != null) {
text = text.replaceAll(RegExp(r"\p{Lu}", unicode: true), capitalCase);
}
if (symbol != null) {
text = text.replaceAll(RegExp(r"\p{P}|\p{S}", unicode: true), symbol);
}
if (number != null) {
text = text.replaceAll(RegExp(r"\p{N}", unicode: true), number);
}
}
}
return text;
}