toCamelCase property

String toCamelCase

Returns the String in camelcase.

Example

String foo = 'Find max of array';
String camelCase = foo.toCamelCase; // returns 'findMaxOfArray'

Implementation

String get toCamelCase {
  if (this.isBlank) {
    return this;
  }

  var words = this.trim().split(RegExp(r'(\s+)'));
  var result = words[0].toLowerCase();
  for (var i = 1; i < words.length; i++) {
    result += words[i].substring(0, 1).toUpperCase() +
        words[i].substring(1).toLowerCase();
  }
  return result;
}