camelCase method

String camelCase([
  1. Pattern? pattern
])

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

Implementation

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

  final buffer = StringBuffer()..write(parts[0]);
  for (var i = 1; i < parts.length; i++) {
    buffer.write(parts[i].capitalize());
  }

  return buffer.toString();
}