randomAlphanumeric function
Returns a random alphanumeric string of length characters.
Draws from lowercase letters and digits by default; set isUppercase to
use uppercase letters instead. A length of zero returns an empty string.
Not cryptographically secure.
Example:
randomAlphanumeric(8); // e.g. 'a3f9k2qd'
Implementation
String randomAlphanumeric(int length, {bool isUppercase = false}) {
const String chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
final String pool = isUppercase ? chars.toUpperCase() : chars;
return List<String>.generate(length, (_) => pool[_rnd.nextInt(pool.length)]).join();
}