tryParse static method

ObjectId? tryParse(
  1. String hexString
)

Generates an ObjectId instance from an hex string If the string is not valid returns null

Implementation

static ObjectId? tryParse(String hexString) =>
    isValidHexId(hexString) ? ObjectId.parse(hexString) : null;