flutter_photo_manager icon indicating copy to clipboard operation
flutter_photo_manager copied to clipboard

feat: Fetch assets by specific type within an album

Open iosephmagno opened this issue 4 months ago • 6 comments

Background & Need

  • The GitHub issue ”[Filter Resource By Type] How to use RequestType to filter inside a specific album? #1257” confirms the lack of this feature.
  • Currently, developers can specify a RequestType globally, but not when fetching assets from a specific album.

Proposed Enhancement:

  • Add an optional RequestType? requestType parameter to album-scoped methods like getAssetListPaged.
  • If requestType is provided, pass it to native code; otherwise, fallback to RequestType.common.

[entity.dart]

  • Allow overriding album type per call, enabling filtering for a specific asset type within an album.

[PMManager.m]

  • Enforce type filtering. A change to native code is required only for the iOS platform.

[main.dart]

  • Add type parameter to getAssetListPaged() for testing the new feature.

[pubspec.yaml]

  • Bump build number.

iosephmagno avatar Aug 14 '25 14:08 iosephmagno

A practical example of this in Presence Messenger: the user can tap the video icon on the right side of the MediaPicker to filter videos in the currently selected album.

IMG_4133

iosephmagno avatar Aug 14 '25 16:08 iosephmagno

I was not able to push to your PR branch, so please make modifications and confirm if they are working properly.

AlexV525 avatar Nov 21 '25 07:11 AlexV525

I also initially updated only the Dart side, but on iOS it was not working without changes at Darwin (tested on iPhone 17 pro, iOS 18.6). No native changes were required on Android.

iosephmagno avatar Nov 21 '25 08:11 iosephmagno

Aside from using a hardcoded type (I was not aware of utils to convert numbers into native enums), the code works correctly.

iosephmagno avatar Nov 21 '25 08:11 iosephmagno

@AlexV525 we tested it in production with Presence Messenger https://apps.apple.com/app/presence-messenger/id6504456930

Here's a video showcasing the feature - user taps the video icon to fetch video-only media within a specific album.

https://github.com/user-attachments/assets/67307048-8c18-4f2f-ba75-976b487031a2

iosephmagno avatar Nov 21 '25 09:11 iosephmagno

Since the code change is small, I think you could merge it and then replace the hardcoded enums afterward.

iosephmagno avatar Nov 21 '25 10:11 iosephmagno