toSlug method
Converts a string to URL slug format: Example: 'My Blog Post!' → 'my-blog-post'
Implementation
String toSlug() {
return toLowerCase()
.replaceAll(RegExp(r'[^\w\s-]'), '')
.trim()
.replaceAll(RegExp(r'\s+'), '-');
}