firstNameWelcome function
Implementation
String? firstNameWelcome(String? firstname) {
// Beginning Of Sentence Case
if (firstname == null || firstname.isEmpty) {
return '';
}
// final firstLetter = firstname.substring(0, 1).toUpperCase();
// final restOfName = firstname.substring(1).toLowerCase();
// return '$firstLetter$restOfName';
List<String> words = firstname.toLowerCase().split(' ');
List<String> capitalizedWords = [];
for (String word in words) {
if (word.isNotEmpty) {
capitalizedWords.add('${word[0].toUpperCase()}${word.substring(1)}');
}
}
return capitalizedWords.join(' ');
}