isValid static method
Whether hexString is a valid ObjectId
Implementation
static bool isValid(String hexString) {
try {
if (hexString.length != 24) return false;
int.parse(hexString.substring(0, 8), radix: 16);
int.parse(hexString.substring(8, 18), radix: 16);
int.parse(hexString.substring(18, 24), radix: 16);
} on FormatException {
return false;
}
return true;
}