toTitleCase method
Formats text to title case.
Example:
final text = "hello there, it's great";
final formatted = text.toTitleCase();
// returns: "Hello There, It's Great"
Implementation
String toTitleCase() {
if (trim().isEmpty) return this;
final regex = RegExp(r'\b\p{L}', unicode: true);
return toLowerCase().replaceAllMapped(
regex,
(match) => match.group(0)!.toUpperCase(),
);
}