getPaths method
Get paths. 获取所有的资源路径
Implementation
@override
Future<void> getPaths({
bool onlyAll = false,
bool keepPreviousCount = 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) {
final int? assetCount;
if (keepPreviousCount) {
assetCount =
_paths.where((e) => e.path.id == p.id).firstOrNull?.assetCount;
} else {
assetCount = null;
}
return PathWrapper<AssetPathEntity>(path: p, assetCount: assetCount);
}).toList();
// Sort path using sort path delegate.
Singleton.sortPathDelegate.sort(_paths);
// Populate fields to paths without awaiting.
for (final path in _paths) {
Future(() async {
await getAssetCountFromPath(path);
await getThumbnailFromPath(path);
});
}
// Set first path entity as current path entity.
if (_paths.isNotEmpty) {
_currentPath ??= _paths.first;
}
if (onlyAll) {
await getAssetsFromCurrentPath();
}
}