toCamelCase method

String toCamelCase()

Converts this String to camel case. Example: "hello world" or "hello_world" or "hello-world" becomes "helloWorld".

Implementation

String toCamelCase() {
  if (isEmptyOrNull) return '';
  String value = validate();
  value = value.replaceAllMapped(RegExp(r'[\s_-]+(\w)'), (Match m) {
    return m.group(1)!.toUpperCase();
  });
  return value[0].toLowerCase() + value.substring(1);
}