toKebabCase static method
Convert string to kebab-case
text - The text to convert
Returns kebab-case string
Implementation
static String toKebabCase(String text) {
return text
.replaceAllMapped(RegExp(r'[A-Z]'), (match) => '-${match.group(0)!.toLowerCase()}')
.replaceAll(RegExp(r'[\s_]+'), '-')
.replaceAll(RegExp(r'^-|-+$'), '')
.toLowerCase();
}