toPascalCase method

String toPascalCase(
  1. String text
)

Converts a string to PascalCase naming convention.

text - The input text to convert.

Splits on underscores, hyphens, and spaces, then converts to PascalCase. Example: 'user_profile' → 'UserProfile'

Implementation

String toPascalCase(String text) {
  if (text.isEmpty) return text;
  final words = text.split(RegExp(r'[_\-\s]+'));
  return words.map((word) => word.capitalize()).join();
}