randomId function

String randomId([
  1. int length = 12
])

Generates a random alpha-numeric ascii encoded value of the specified length (defaults to 12).

Implementation

String randomId([int length = 12]) {
  final max = _asciiChars.length - 1;
  return ascii.decode(List.generate(
    length,
    (index) => _asciiChars[randomInt(0, max)],
  ));
}