generateBasicId static method

String generateBasicId({
  1. int length = 30,
})

Implementation

static String generateBasicId({int length: 30}) {
  var r0 = Random();
  var buffer = StringBuffer();
  for (int i = 1; i <= length; i++) {
    var r = Random(r0.nextInt(0x70000000) + (DateTime.now()).millisecondsSinceEpoch);
    var n = r.nextInt(50);
    if (n >= 0 && n <= 32) {
      String letter = alphabet[r.nextInt(alphabet.length)];
      buffer.write(r.nextBool() ? letter.toLowerCase() : letter);
    } else if (n > 32 && n <= 43) {
      buffer.write(numbers[r.nextInt(numbers.length)]);
    } else if (n > 43) {
      buffer.write(specials[r.nextInt(specials.length)]);
    }
  }
  return buffer.toString();
}