From c51a34e70db30f35db5da0f1804138745253edcb Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 22 Oct 2020 15:52:02 +0800 Subject: [PATCH 1/2] Fix: use sub path /Document/photo_gallery to save file --- ios/Classes/SwiftPhotoGalleryPlugin.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/SwiftPhotoGalleryPlugin.swift b/ios/Classes/SwiftPhotoGalleryPlugin.swift index 5557628..50d2c4a 100644 --- a/ios/Classes/SwiftPhotoGalleryPlugin.swift +++ b/ios/Classes/SwiftPhotoGalleryPlugin.swift @@ -409,7 +409,7 @@ public class SwiftPhotoGalleryPlugin: NSObject, FlutterPlugin { let tempFolder = paths[0].appendingPathComponent("photo_gallery") try! FileManager.default.createDirectory(at: tempFolder, withIntermediateDirectories: true, attributes: nil) - return paths[0].appendingPathComponent(mediumId+ext) + return tempFolder.appendingPathComponent(mediumId+ext) } private func toSwiftMediumType(value: String) -> PHAssetMediaType? { From f742e6e6661856cacb5cdf8579f6155d84886517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BA=B7ng=20Ng=E1=BB=8Dc=20Qu=E1=BA=A3ng?= Date: Tue, 24 Nov 2020 15:54:33 +0700 Subject: [PATCH 2/2] fix collection nil --- ios/Classes/SwiftPhotoGalleryPlugin.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Classes/SwiftPhotoGalleryPlugin.swift b/ios/Classes/SwiftPhotoGalleryPlugin.swift index 5557628..30ac521 100644 --- a/ios/Classes/SwiftPhotoGalleryPlugin.swift +++ b/ios/Classes/SwiftPhotoGalleryPlugin.swift @@ -161,7 +161,7 @@ public class SwiftPhotoGalleryPlugin: NSObject, FlutterPlugin { return PHAsset.fetchAssets(with: options).count } - return PHAsset.fetchAssets(in: collection!, options: options).count + return PHAsset.fetchAssets(in: collection ?? PHAssetCollection.init(), options: options).count } private func listMedia(albumId: String, skip: NSNumber?, take: NSNumber?, mediumType: String) -> NSDictionary { @@ -175,7 +175,7 @@ public class SwiftPhotoGalleryPlugin: NSObject, FlutterPlugin { let fetchResult = albumId == "__ALL__" ? PHAsset.fetchAssets(with: fetchOptions) - : PHAsset.fetchAssets(in: collection!, options: fetchOptions) + : PHAsset.fetchAssets(in: collection ?? PHAssetCollection.init(), options: fetchOptions) let start = skip?.intValue ?? 0 let total = fetchResult.count let end = take == nil ? total : min(start + take!.intValue, total)