toSlug method
Converts the string to a slug by replacing spaces and non-alphanumeric characters.
The resulting slug is lowercase and uses hyphens instead of spaces. Non-alphanumeric characters are removed.
Returns the slugified version of the original string.
Implementation
String toSlug() {
String slug = trim().toLowerCase();
slug = slug.replaceAll(RegExp(r'\s+'), '-');
slug = slug.replaceAll(RegExp(r'[^a-z0-9\-]'), '');
return slug;
}