camelCaseToLowerUnderscore static method
Transfers the given String s
from camcelCase to lowerCaseUnderscore
Example : helloWorld => hello_world
Implementation
static String camelCaseToLowerUnderscore(String s) {
var sb = StringBuffer();
var first = true;
s.runes.forEach((int rune) {
var char = String.fromCharCode(rune);
if (isUpperCase(char) && !first) {
if (char != '_') {
sb.write('_');
}
sb.write(char.toLowerCase());
} else {
first = false;
sb.write(char.toLowerCase());
}
});
return sb.toString();
}