randomUUID function
Get a random UUID
Implementation
String randomUUID() {
final output = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replaceAllMapped(RegExp('[xy]'), (match) {
final random = (Random().nextDouble() * 16).floor();
return (match.group(0) == 'x' ? random : (random & 0x3) | 0x8)
.toRadixString(16);
});
return output;
}