Guid.tryParseString constructor

Guid.tryParseString(
  1. String guid
)

Initializes a new instance of the Guid structure by using the value represented by the specified string.

Like parseString except that this function returns null where a similar call to parse would throw a FormatException.

Implementation

factory Guid.tryParseString(String guid) {
  if (guid.isNotEmpty && _Guid.isValidGUID(fromString: guid)) {
    return Guid._(GuidValue(guid, _Guid.parse(guid)));
  }

  return Guid._();
}