parseDownloadStatus function

DownloadStatus? parseDownloadStatus(
  1. String? value
)

Parses normalized and Apple-native download status strings.

Implementation

DownloadStatus? parseDownloadStatus(String? value) {
  if (value == null) return null;

  switch (value) {
    case 'notDownloaded':
    case 'NSMetadataUbiquitousItemDownloadingStatusNotDownloaded':
    case 'NSURLUbiquitousItemDownloadingStatusNotDownloaded':
      return DownloadStatus.notDownloaded;
    case 'downloaded':
    case 'NSMetadataUbiquitousItemDownloadingStatusDownloaded':
    case 'NSURLUbiquitousItemDownloadingStatusDownloaded':
      return DownloadStatus.downloaded;
    case 'current':
    case 'NSMetadataUbiquitousItemDownloadingStatusCurrent':
    case 'NSURLUbiquitousItemDownloadingStatusCurrent':
      return DownloadStatus.current;
    default:
      _logger.warning('Unknown download status from native metadata: $value');
      return null;
  }
}