Skip to content

Conversation

@iosephmagno
Copy link

@iosephmagno iosephmagno commented Aug 14, 2025

Background & Need

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.

**Background & Need**
- The GitHub issue ”[Filter Resource By Type] How to use RequestType to filter inside a specific album? fluttercandies#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.

[main.dart]
- Add type parameter to getAssetListPaged() for testing the new feature.

[pubspec.yaml]
- Bump build number.
@iosephmagno
Copy link
Author

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

page: page,
size: size,
type: type,
type: type ?? RequestType.common, // use album type by default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be type ?? this.type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should, I don't remember why I forced a fallback.

description: A Flutter plugin that provides album assets abstraction management APIs on Android, iOS, macOS, and OpenHarmony.
repository: https://github.com/fluttercandies/flutter_photo_manager
version: 3.7.1
version: 3.7.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert

Comment on lines +276 to +280
// 'type' here is a bitmask based on PhotoManager's RequestType enum:
// 1 = image
// 2 = video
// 3 = common (image + video) <-- THIS IS THE "COMMON" CASE
// 4 = audio
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we have utils to convert these numbers into specific native enums. Is it true? The code here seems to be a bit of hard-coded also.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didnt know about Utils. We should definitely use them.

Would you be so kind as to make these minor changes? I won't be able to work on this for a while.

I quickly added this feat to our fork and is the only difference compared to the official repo.

final List<AssetEntity> entities = await _path!.getAssetListPaged(
page: 0,
size: _sizePerPage,
type: RequestType.common, // Switch to .video or .image to filter album assets by format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we imply the type from the path, then these are unnecessary.

Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon reviewing the code, I'm unsure whether we need to update the Darwin implementation. The ability to filter corresponding assets appears to have been implemented; the only thing we need to add is parameters on the Dart side.

@AlexV525
Copy link
Member

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

@iosephmagno
Copy link
Author

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
Copy link
Author

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

@iosephmagno
Copy link
Author

@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.

ScreenRecording_11-21-2025.10-53-50_1.mp4

@iosephmagno
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants