parseName static method
Implementation
static String parseName(String name, int? letterLimit) {
// separate each word
var parts = name.split(' ');
var initial = '';
// check length
if (parts.length > 1) {
// check max limit
if (letterLimit != null) {
for (var i = 0; i < letterLimit; i++) {
// combine the first letters of each word
initial += parts[i][0];
}
} else {
// this default, if word > 1
initial = parts[0][0] + parts[1][0];
}
} else {
// this default, if word <=1
initial = parts[0][0];
}
return initial;
}