Guid.parseList constructor

Guid.parseList(
  1. List<int> guid
)

Initializes a new instance of the Guid structure by using the specified List of int.

If the guid does not contain a valid literal, optionally prefixed by a sign, a FormatException is thrown.

Instead of throwing and immediately catching the FormatException, instead use tryParseList to handle a parsing error.

Implementation

factory Guid.parseList(List<int> guid) {
  if (guid.isEmpty) {
    throw FormatException('Value "$guid" is empty');
  }

  final Uint8List bytes = Uint8List.fromList(guid);

  if (_Guid.isValidGUID(fromByteList: bytes)) {
    return Guid._(GuidValue(_Guid.unparse(bytes), bytes));
  } else {
    throw FormatException('Value "$guid" is not a valid GUID');
  }
}