Open webnickell opened 1 year ago
Like the link you posted, the options for filtering can only be those you mentioned, because of efficiency issues, we must rely on the native PHFetchOptions to do it.
Yes, I understand it. That's why I propose use other steps to filter it. I mean, that we need to add this functionality in library and we can add it in other steps. We don't need to be blocked with PHFetchOptions, because we can use other ways.
That should be more about business logic, so should I close this issue?
@CaiJingLong why do you talk that it's business logic? I don't think so. It's on data side and should be handled by library. At first, it will be very slow if you want to get list of media, but you need only specific type. Because on flutter side you can filter in two ways and both are terrible: filter by extension from file name (but here we don't handle media without extension) or filter with property mimeTypeAsync( and here we need to make a lot calls on native side for 100+ media). Also both that variants could be terrible according to pagination handling, because we'll have different page length. On native side it's easily to filter on data layer, and we should have this functionality on flutter, which proxy filtration on native side.
PHAsset has no mimeType, and fileName also needs to obtain all resources, then traverse and obtain the corresponding filename, and then filter, instead of directly completing it through fetchOption. Therefore, if native filtering is required, all resources need to be traversed even in native, which does not improve efficiency, nor is it what native should provide.
The PhotoManager library is only a native package wrapper, and the content not provided by the native is all business logic.
For your problem, you can set the needTitle
for the PMFilter
to true, and then the title attribute in the AssetEntity in dart is not null, and you can filter on the dart side.
Platforms
iOS, macOS
Description
There is no way to filter media by its extension (jpeg, png). Currently we can use only this keys https://developer.apple.com/documentation/photokit/phfetchoptions . And as you can see most appropriate is mediaType and mediaSubtypes . First is already implemented and it can filter only image/video, but mediaSubtypes completely useless because it helps us to use very strange list of values https://developer.apple.com/documentation/photokit/phassetmediasubtype , actually I have no idea when they can be useful in real-world applications. I suggest to use https://developer.apple.com/documentation/uniformtypeidentifiers . It'll help us to filter files by this identifiers. But currently we don't have any possibility to use it. Actually it would be great, if you can create special filter params which will be cross platform. It could use mimeType on android and identifiers on iOS. Because I spent a lot time to find solution for filtering, and currently can support only Android.
Why
No response