toNamingConvention function
Implementation
String toNamingConvention(String input, NamingConvention convention) {
switch (convention) {
case NamingConvention.none:
return input;
case NamingConvention.lowerSnakeCase:
return splitWords(input).map((e) => e.toLowerCase()).join('_');
case NamingConvention.upperSnakeCase:
return splitWords(input).map((e) => e.toUpperCase()).join('_');
case NamingConvention.camelCase:
return splitWords(input).map((e) => firstUpper(e)).join();
case NamingConvention.lowerCamelCase:
return splitWords(input)
.mapIndexed((e, i) => i == 0 ? e.toLowerCase() : firstUpper(e))
.join();
}
}