initials property
String
get
initials
Implementation
String get initials {
final words = trim()
.split(RegExp(r'\s+'))
.where((word) => word.isNotEmpty)
.toList();
if (words.isEmpty) return '';
if (words.length == 1) {
return words.first.substring(0, 1).toUpperCase();
}
return '${words.first[0]}${words.last[0]}'.toUpperCase();
}