capitalizeSentences method
Capitalizes the first letter after sentence boundaries (start or after . ).
Audited: 2026-06-12 11:26 EDT
Implementation
@useResult
String capitalizeSentences() {
if (isEmpty) return this;
final RegExp re = RegExp(r'(^|\.\s+)([a-z])');
return replaceAllMapped(
re,
(Match m) {
final prefixGroup = m[1];
final letterGroup = m[2];
return '${prefixGroup ?? ''}${(letterGroup ?? '').toUpperCase()}';
},
);
}