toPascalCase function

String toPascalCase(
  1. String text
)

Converts any string to PascalCase (UpperCamelCase).

Implementation

String toPascalCase(String text) {
  if (text.isEmpty) return "";
  return toSnakeCase(text)
      .split('_')
      .where((word) => word.isNotEmpty)
      .map((word) => word[0].toUpperCase() + word.substring(1))
      .join('');
}