toPascalCase method
Converts the string to PascalCase (e.g., "hello world" -> "HelloWorld").
Capitalizes the first letter of each word and removes spaces.
Example:
"hello world".toPascalCase(); // Returns "HelloWorld"
"snake_case".toPascalCase(); // Returns "SnakeCase"
Implementation
String toPascalCase() {
if (isEmpty) return this;
return trim().split(RegExp(r'[\s_]+')).map((word) {
if (word.isEmpty) return word;
return word[0].toUpperCase() + word.substring(1).toLowerCase();
}).join();
}