getUniqueID method
Implementation
String getUniqueID([int length = 4, bool timeStamp = true]) {
int timestamp = DateTime.now().millisecondsSinceEpoch;
String randomStr(int length) {
const characters =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
String randomString = '';
for (int i = 0; i < length; i++) {
int randomIndex =
DateTime.now().millisecondsSinceEpoch % characters.length;
randomString += characters[randomIndex];
}
return randomString;
}
return "${timeStamp ? timestamp.toRadixString(36) : ""}${randomStr(length)}";
}