decapitalize method

String decapitalize()

Returns a copy of this string having its first letter lowercased, or the original string, if it's empty or already starts with a lower case letter.

print('abcd'.decapitalize()) // abcd
print('Abcd'.decapitalize()) // abcd

Implementation

String decapitalize() {
  switch (length) {
    case 0:
      return this;
    case 1:
      return toLowerCase();
    default:
      return this[0].toLowerCase() + substring(1);
  }
}