toCase method
transforms the string to the specified case if case is null, then no transformation will be applied
Implementation
String toCase(CaseStyle? style) {
switch (style) {
case CaseStyle.camel:
return getWords()
.mapIndexed((index, word) =>
index == 0 ? word.toLowerCase() : word.capitalize())
.join('');
case CaseStyle.pascal:
return getWords().map((word) => word.capitalize()).join('');
case CaseStyle.snake:
return getWords().map((word) => word.toLowerCase()).join('_');
case null:
return this;
default:
print('Unknown case: $style');
return this;
}
}