decapitalize method
Returns a copy of this string having its first letter lowercased.
This function does not change the case of any letters other than the first one, as opposed to MyUtilityExtensionStringCapitalize.capitalize.
void foo() {
print('abcd'.capitalize()); // 'abcd'
print(''.capitalize()); // ''
print('Abcd'.capitalize()); // 'abcd'
print('ABCD'.capitalize()); // 'aBCD'
}
Implementation
String decapitalize() {
switch (length) {
case 0:
return this;
case 1:
return toLowerCase();
default:
return substring(0, 1).toLowerCase() + substring(1);
}
}