moveToSharedStorage method

Future<String?> moveToSharedStorage(
  1. DownloadTask task,
  2. SharedStorage destination, {
  3. String directory = '',
  4. String? mimeType,
})

Move the file represented by the task to a shared storage destination and potentially a directory within that destination. If the mimeType is not provided we will attempt to derive it from the Task.filePath extension

Returns the path to the stored file, or null if not successful

NOTE: on iOS, using destination SharedStorage.images or SharedStorage.video adds the photo or video file to the Photos library. This requires the user to grant permission, and requires the "NSPhotoLibraryAddUsageDescription" key to be set in Info.plist. The returned value is NOT a filePath but an identifier. If the full filepath is required, follow the moveToSharedStorage call with a call to pathInSharedStorage, passing the identifier obtained from the call to moveToSharedStorage as the filePath parameter. This requires the user to grant additional permissions, and requires the "NSPhotoLibraryUsageDescription" key to be set in Info.plist. The returned value is the actual file path of the photo or video in the Photos Library.

Platform-dependent, not consistent across all platforms

Implementation

Future<String?> moveToSharedStorage(
  DownloadTask task,
  SharedStorage destination, {
  String directory = '',
  String? mimeType,
}) async =>
    moveFileToSharedStorage(await task.filePath(), destination,
        directory: directory, mimeType: mimeType);