generateV4 static method

String generateV4()

Generate a version 4 (random) uuid. This is a uuid scheme that only uses random numbers as the source of the generated uuid.

Implementation

static String generateV4() {
  // Generate xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx / 8-4-4-4-12.
  final int special = 8 + Random().nextInt(4);
  return '${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}-'
      '${_bitsDigits(16, 4)}-'
      '4${_bitsDigits(12, 3)}-'
      '${_printDigits(special, 1)}${_bitsDigits(12, 3)}-'
      '${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}';
}