generateV4 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

String generateV4() {
  // Generate xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx / 8-4-4-4-12.
  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)}';
}