slugify method

String slugify()

Lowercases, collapses whitespace and non-alphanumerics into single hyphens.

Implementation

String slugify() => trim()
    .toLowerCase()
    .replaceAll(RegExp(r'[^a-z0-9]+'), '-')
    .replaceAll(RegExp(r'^-+|-+$'), '');