randomString function

String randomString([
  1. int length = 10
])

Generates a random string of the specified length. The generated string consists of random alphanumeric and special characters.

Implementation

String randomString([int length = 10]) {
  var chars = [...alphaNumericChars, specialChars];
  return List.generate(length, (index) => [randomInt(0, chars.length - 1)]).join();
}