slugify method

String slugify()

Converts the string to a slug.

Returns the slugified string.

Implementation

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