ObjectTypeId.fromIdentifier constructor

ObjectTypeId.fromIdentifier(
  1. String identifier
)

Implementation

factory ObjectTypeId.fromIdentifier(String identifier) {
  final values = <ObjectTypeId>[
    ...HKSampleTypeIdentifier.values,
    ...HKQuantityTypeIdentifier.values,
    ...HKCategoryTypeIdentifier.values,
    ...HKCharacteristicTypeIdentifier.values,
    ...HKCorrelationTypeIdentifier.values,
    ...HKDocumentTypeIdentifier.values,
  ];
  final type = values.firstWhereOrNull(
    (e) => e.identifier == identifier,
  );
  if (type == null) {
    throw ArgumentError.value(
      identifier,
      'identifier',
      'Invalid identifier: $identifier',
    );
  }
  return type;
}