toCamelCase method

String toCamelCase()

Converts the string to camelCase.

Implementation

String toCamelCase() {
  final words = split(RegExp(r'[_\s-]+'));
  if (words.isEmpty) return this;
  final firstWord = words.first.toLowerCase();
  final capitalizedWords = words.skip(1).map((word) => word.capitalize());
  return [firstWord, ...capitalizedWords].join();
}