toSlug method
Converts this string to URL-friendly slug (e.g. 'Hello World!' -> 'hello-world').
Implementation
String toSlug() => toLowerCase()
.trim()
.replaceAll(RegExp(r'[^\w\s-]'), '')
.replaceAll(RegExp(r'[\s_-]+'), '-')
.replaceAll(RegExp(r'^-+|-+$'), '');