[Feat] added String camelcase to title extension.
This commit is contained in:
2
debug.log
Normal file
2
debug.log
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[0330/121753.404:ERROR:crashpad_client_win.cc(811)] not connected
|
||||||
|
[0330/121753.573:ERROR:crashpad_client_win.cc(811)] not connected
|
||||||
@@ -16,4 +16,14 @@ extension StringExtensions on String {
|
|||||||
String get capitalize {
|
String get capitalize {
|
||||||
return (length > 1) ? this[0].toUpperCase() + substring(1) : toUpperCase();
|
return (length > 1) ? this[0].toUpperCase() + substring(1) : toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert CamelCase to a capitalized space separated title.
|
||||||
|
String camelCaseToTitle(String input) {
|
||||||
|
final spaced = input.replaceAllMapped(
|
||||||
|
RegExp(r'([a-z])([A-Z])'),
|
||||||
|
(match) => '${match.group(1)} ${match.group(2)}',
|
||||||
|
);
|
||||||
|
|
||||||
|
return spaced.split(' ').map((word) => word[0].toUpperCase() + word.substring(1)).join(' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user