formatName static method
Implementation
static String formatName(String text, {type = "text"}) {
if (text == "" || text == null) return "";
if (type == 'phone') {
return text.replaceFirst(new RegExp(r'\d{4}'), '****', 3);
} else {
if (text.length > 2) {
return text.replaceFirst(new RegExp('.'), '*', 1);
}
return text.substring(0, 1) + '*';
}
}