Source
String generateToken({int length: 50}) { var r0 = new Random(); var buffer = new StringBuffer(); for (int i = 1; i <= length; i++) { var r = new Random(r0.nextInt(0x70000000) + (new DateTime.now()).millisecondsSinceEpoch); if (r.nextBool()) { String letter = alphabet[r.nextInt(alphabet.length)]; buffer.write(r.nextBool() ? letter.toLowerCase() : letter); } else { buffer.write(numbers[r.nextInt(numbers.length)]); } } return buffer.toString(); }