pascal static method

String pascal(
  1. String text
)

Converts a string to PascalCase.

Implementation

static String pascal(String text) {
  if (text.isEmpty) return '';
  return text
      .split(RegExp(r'(_|(?=[A-Z]))'))
      .where((word) => word.isNotEmpty)
      .map((word) => word[0].toUpperCase() + word.substring(1).toLowerCase())
      .join('');
}