Skip to content

Commit 9472521

Browse files
authored
🐛 Fix merging filter options (#440)
1 parent 58b0468 commit 9472521

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

lib/src/provider/asset_picker_provider.dart

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,25 +299,31 @@ class DefaultAssetPickerProvider
299299

300300
@override
301301
Future<void> getPaths() async {
302-
// Initial base options.
303-
// Enable need title for audios and image to get proper display.
304-
final FilterOptionGroup options = FilterOptionGroup(
305-
imageOption: const FilterOption(
306-
needTitle: true,
307-
sizeConstraint: SizeConstraint(ignoreSize: true),
308-
),
309-
audioOption: const FilterOption(
310-
needTitle: true,
311-
sizeConstraint: SizeConstraint(ignoreSize: true),
312-
),
313-
containsPathModified: sortPathsByModifiedDate,
314-
createTimeCond: DateTimeCond.def().copyWith(ignore: true),
315-
updateTimeCond: DateTimeCond.def().copyWith(ignore: true),
316-
);
317-
318-
// Merge user's filter option into base options if it's not null.
319-
if (filterOptions is FilterOptionGroup) {
320-
options.merge(filterOptions as FilterOptionGroup);
302+
final PMFilter options;
303+
final PMFilter? fog = filterOptions;
304+
if (fog is FilterOptionGroup?) {
305+
// Initial base options.
306+
// Enable need title for audios and image to get proper display.
307+
final FilterOptionGroup newOptions = FilterOptionGroup(
308+
imageOption: const FilterOption(
309+
needTitle: true,
310+
sizeConstraint: SizeConstraint(ignoreSize: true),
311+
),
312+
audioOption: const FilterOption(
313+
needTitle: true,
314+
sizeConstraint: SizeConstraint(ignoreSize: true),
315+
),
316+
containsPathModified: sortPathsByModifiedDate,
317+
createTimeCond: DateTimeCond.def().copyWith(ignore: true),
318+
updateTimeCond: DateTimeCond.def().copyWith(ignore: true),
319+
);
320+
// Merge user's filter options into base options if it's not null.
321+
if (fog != null) {
322+
newOptions.merge(fog);
323+
}
324+
options = newOptions;
325+
} else {
326+
options = fog;
321327
}
322328

323329
final List<AssetPathEntity> list = await PhotoManager.getAssetPathList(

0 commit comments

Comments
 (0)