@@ -273,7 +273,10 @@ class DefaultAssetPickerProvider
273
273
}) {
274
274
Singleton .sortPathDelegate = sortPathDelegate ?? SortPathDelegate .common;
275
275
// Call [getAssetList] with route duration when constructing.
276
- Future <void >.delayed (initializeDelayDuration, getPaths);
276
+ Future <void >.delayed (initializeDelayDuration, () async {
277
+ await getPaths (onlyAll: true );
278
+ await getPaths (onlyAll: false );
279
+ });
277
280
}
278
281
279
282
@visibleForTesting
@@ -326,41 +329,40 @@ class DefaultAssetPickerProvider
326
329
}
327
330
328
331
@override
329
- Future <void > getPaths () async {
332
+ Future <void > getPaths ({ bool onlyAll = false } ) async {
330
333
final PMFilter options;
331
- final PMFilter ? fog = filterOptions;
332
- if (fog is FilterOptionGroup ? ) {
333
- // Initial base options.
334
- // Enable need title for audios to get proper display.
335
- final FilterOptionGroup newOptions = FilterOptionGroup (
334
+ final fog = filterOptions;
335
+ if (fog == null ) {
336
+ options = AdvancedCustomFilter (
337
+ orderBy: [OrderByItem .desc (CustomColumns .base .createDate)],
338
+ );
339
+ } else if (fog is FilterOptionGroup ) {
340
+ final newOptions = FilterOptionGroup (
336
341
imageOption: const FilterOption (
337
342
sizeConstraint: SizeConstraint (ignoreSize: true ),
338
343
),
339
344
audioOption: const FilterOption (
345
+ // Enable title for audios to get proper display.
340
346
needTitle: true ,
341
347
sizeConstraint: SizeConstraint (ignoreSize: true ),
342
348
),
343
349
containsPathModified: sortPathsByModifiedDate,
344
350
createTimeCond: DateTimeCond .def ().copyWith (ignore: true ),
345
351
updateTimeCond: DateTimeCond .def ().copyWith (ignore: true ),
346
352
);
347
- // Merge user's filter options into base options if it's not null.
348
- if (fog != null ) {
349
- newOptions.merge (fog);
350
- }
353
+ newOptions.merge (fog);
351
354
options = newOptions;
352
355
} else {
353
356
options = fog;
354
357
}
355
358
356
- final List < AssetPathEntity > list = await PhotoManager .getAssetPathList (
359
+ final list = await PhotoManager .getAssetPathList (
357
360
type: requestType,
358
361
filterOption: options,
362
+ onlyAll: onlyAll,
359
363
);
360
364
361
- _paths = list
362
- .map ((AssetPathEntity p) => PathWrapper <AssetPathEntity >(path: p))
363
- .toList ();
365
+ _paths = list.map ((p) => PathWrapper <AssetPathEntity >(path: p)).toList ();
364
366
// Sort path using sort path delegate.
365
367
Singleton .sortPathDelegate.sort (_paths);
366
368
// Use sync method to avoid unnecessary wait.
@@ -373,17 +375,19 @@ class DefaultAssetPickerProvider
373
375
_currentPath ?? = _paths.first;
374
376
}
375
377
376
- await getAssetsFromCurrentPath ();
378
+ if (onlyAll) {
379
+ await getAssetsFromCurrentPath ();
380
+ }
377
381
}
378
382
379
383
Completer <void >? _getAssetsFromPathCompleter;
380
384
381
385
@override
382
386
Future <void > getAssetsFromPath ([int ? page, AssetPathEntity ? path]) {
383
387
Future <void > run () async {
384
- final int currentPage = page ?? currentAssetsListPage;
385
- final AssetPathEntity currentPath = path ?? this .currentPath! .path;
386
- final List < AssetEntity > list = await currentPath.getAssetListPaged (
388
+ final currentPage = page ?? currentAssetsListPage;
389
+ final currentPath = path ?? this .currentPath! .path;
390
+ final list = await currentPath.getAssetListPaged (
387
391
page: currentPage,
388
392
size: pageSize,
389
393
);
0 commit comments