pascalCase method

String pascalCase([
  1. Pattern? pattern
])

Pascal-cases this String with separations determined using the given pattern.

Implementation

String pascalCase([Pattern? pattern]) {
  final parts = split(pattern ?? _delimiters)..removeWhere((val) => val.isEmpty);
  if (parts.isEmpty) {
    return this;
  }

  final buffer = StringBuffer();
  for (final part in parts) {
    buffer.write(part.capitalize());
  }

  return buffer.toString();
}