asSlug property

String get asSlug

Converts the string to a URL-friendly slug.

Removes accents, trims, replaces non-word characters with "-", removes duplicate hyphens.

Implementation

String get asSlug => noAccent
    .trim()
    .toLowerCase()
    .replaceAll(RegExp(r'[^\w]+'), '-')
    .replaceAll(RegExp(r'-+'), '-')
    .replaceAll(RegExp(r'^-|-$'), '');