Skip to content

How to use CustomFilter.sql to filter android special mime_type. #927

Answered by CaiJingLong
YanhqZ asked this question in Q&A
Discussion options

You must be logged in to vote

Have two questions:

  1. This is a like sql, strings need to be wrapped in single quotes instead of double quotes.
  2. mediaType has document comments, which represent video, image or audio.

So I think you maybe need mimeType :

Future<void> _reproduct() async {
    PMFilter? createFilterOption() {
      return CustomFilter.sql(
        where: '''${CustomColumns.android.mimeType} = 'image/png' ''',
      );
    }

    final assetCount = await PhotoManager.getAssetCount(
      filterOption: createFilterOption(),
      type: RequestType.all,
    );

    print('assets count: $assetCount');
  }

By the way, mimeType just support android, you need to handle the logic of iOS by yourself.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@YanhqZ
Comment options

Answer selected by CaiJingLong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Type: Custom filter About CustomFilter problem.
2 participants
Converted from issue

This discussion was converted from issue #925 on April 18, 2023 05:12.