firstChar method
'John Doe'.firstChar(length = 2); // JD
Implementation
String firstChar({bool firstUppercase = true, int length = 2}) {
String result = '';
try {
List<String> char = trim().split(' ');
char
.take(length)
.forEach((e) => result += firstUppercase ? e[0].ucwords : e[0]);
return result;
} catch (e) {
return '!';
}
}