slug static method

String slug(
  1. String text
)

Formats a string as a slug

Example:

StringFormatters.slug('Hello World!'); // 'hello-world'

Implementation

static String slug(String text) => text
    .toLowerCase()
    .replaceAll(RegExp(r'[^\w\s-]'), '')
    .replaceAll(RegExp(r'[-\s]+'), '-')
    .trim();