getIDsWhereMimeTypeOf method

List<String> getIDsWhereMimeTypeOf(
  1. MimeType? mimeType, {
  2. bool matchSubType = true,
})

Returns a list of IDs of mimeType.

matchSubType If true also matches the mimeType.subType.

Implementation

List<String> getIDsWhereMimeTypeOf(MimeType? mimeType,
    {bool matchSubType = true}) {
  if (mimeType == null) return [];

  var ids = _assets.entries
      .where((e) {
        var entryMimeType = e.value.mimeType;
        if (entryMimeType == null) return false;

        if (entryMimeType.type == mimeType.type) {
          if (!matchSubType) return true;
          entryMimeType.subType == mimeType.subType;
        }
        return false;
      })
      .map((e) => e.key)
      .toList();

  return ids;
}