toKebabCase method

String toKebabCase()

String Conversion: Extensions for converting a string to formats like snake_case or kebab-case.

Implementation

String toKebabCase() {
  return replaceAllMapped(
          RegExp(r'([A-Z])'), (match) => '-${match.group(1)!.toLowerCase()}')
      .toLowerCase();
}