toSlug property
String
get
toSlug
URL-safe slug: lowercased, spaces->hyphens, non-alphanumeric stripped.
'Hello World! 2024' -> 'hello-world-2024'
Implementation
String get toSlug =>
toLowerCase()
.replaceAll(_whitespaceRegExp, '-')
.replaceAll(_slugUnsafeRegExp, '')
.replaceAll(_slugHyphenRegExp, '-')
.trimHyphens();