toKebabCase property
String
get
toKebabCase
Converts the string to hyphen case.
- This method splits the string by spaces, hyphens, or underscores and then joins the words with kebab in lowercase.
- Returns a new string in kebab case, with all words in lowercase and separated by hyphens.
Example:
"Hello World".toKebabCase; // Returns "hello-world"
Returns: A String in kebab case.
Implementation
String get toKebabCase {
return split(RegExp(r'[\s_-]+'))
.map((word) => word.toLowerCase())
.join('-');
}