textCapitalize method
Capitalizes the first letter of each word in the text.
Matches Bootstrap's .text-capitalize class.
Implementation
Text textCapitalize() {
if (data != null && data!.isNotEmpty) {
final words = data!.split(' ');
final capitalizedWords = words.map((w) {
if (w.isEmpty) return '';
return w[0].toUpperCase() + w.substring(1).toLowerCase();
});
return _copyWithText(capitalizedWords.join(' '));
}
return this;
}