slugify function
Converts a string to a slug.
The text parameter is the string to be converted to a slug.
Returns the slugified string.
Implementation
String slugify(String text) {
return text
.trim()
.toLowerCase()
.replaceAll(RegExp(r'[^a-z0-9]'), '-')
.replaceAll(RegExp(r'-+'), '-')
.replaceAll(RegExp(r'^-+|-+$'), '');
}