isSlug function

bool isSlug(
  1. String str
)

Checks if the string is a valid URL slug.

A slug contains only lowercase letters, digits and single hyphens, and must not start or end with a hyphen.

Example:

isSlug('my-blog-post'); // true
isSlug('post-123'); // true
isSlug('-leading'); // false
isSlug('double--hyphen'); // false

Implementation

bool isSlug(String str) => _isSlug(str);