convertToKebabCase function Null safety

String convertToKebabCase(
  1. String camelCase
)

The function used to convert camelCase identifiers to Discord compatible kebab-case names

Implementation

String convertToKebabCase(String camelCase) {
  Iterable<String> split = camelCase.split('');
  String res = '';

  for (final char in split) {
    if (char != char.toLowerCase() && res.isNotEmpty) {
      res += '-';
    }
    res += char.toLowerCase();
  }

  return res;
}