toPascalCase method

String toPascalCase()

Converts this String to PascalCase. Example: "hello world" or "hello_world" becomes "HelloWorld".

Implementation

String toPascalCase() {
  if (isEmptyOrNull) return '';
  String value = validate();
  value = value.split(RegExp(r'[\s_-]+')).map((word) {
    if (word.isEmpty) return '';
    return word[0].toUpperCase() + word.substring(1).toLowerCase();
  }).join();
  return value;
}