getPaths method
Get paths. 获取所有的资源路径
Implementation
@override
Future<void> getPaths({bool onlyAll = false}) async {
final PMFilter options;
final fog = filterOptions;
if (fog == null) {
options = AdvancedCustomFilter(
orderBy: [OrderByItem.desc(CustomColumns.base.createDate)],
);
} else if (fog is FilterOptionGroup) {
final newOptions = FilterOptionGroup(
imageOption: const FilterOption(
sizeConstraint: SizeConstraint(ignoreSize: true),
),
audioOption: const FilterOption(
// Enable title for audios to get proper display.
needTitle: true,
sizeConstraint: SizeConstraint(ignoreSize: true),
),
containsPathModified: sortPathsByModifiedDate,
createTimeCond: DateTimeCond.def().copyWith(ignore: true),
updateTimeCond: DateTimeCond.def().copyWith(ignore: true),
);
newOptions.merge(fog);
options = newOptions;
} else {
options = fog;
}
final list = await PhotoManager.getAssetPathList(
type: requestType,
filterOption: options,
onlyAll: onlyAll,
);
_paths = list.map((p) => PathWrapper<AssetPathEntity>(path: p)).toList();
// Sort path using sort path delegate.
Singleton.sortPathDelegate.sort(_paths);
// Use sync method to avoid unnecessary wait.
_paths
..forEach(getAssetCountFromPath)
..forEach(getThumbnailFromPath);
// Set first path entity as current path entity.
if (_paths.isNotEmpty) {
_currentPath ??= _paths.first;
}
if (onlyAll) {
await getAssetsFromCurrentPath();
}
}