extractNamesInitials function
extractNamesInitials => Extracts name initials from a name
Usage:
If you pass in a name like 'Abiud Orina', it returns 'AO'
Implementation
String extractNamesInitials({required String name}) {
final List<String> parts = name.split(' ');
if (parts.length >= 2) {
final StringBuffer initials = StringBuffer();
for (int i = 0; i <= 1; i++) {
final String part = parts[i];
initials.write(part[0].toUpperCase());
}
return initials.toString().trim().substring(0, 2);
}
return parts.first.split('')[0].toUpperCase();
}