getAssetListRange method
Getting assets in range using start
and end
.
The start
and end
are similar to String.substring, but it'll return
the maxmium assets if the total count of assets is fewer than the range,
instead of throwing a RangeError like String.substring.
Implementation
Future<List<AssetEntity>> getAssetListRange({
required int start,
required int end,
}) async {
assert(albumType == 1, 'Only album can request for assets.');
assert(start >= 0, 'The start must be greater than 0.');
assert(end > start, 'The end must be greater than start.');
final filterOption = this.filterOption;
if (filterOption is FilterOptionGroup) {
assert(
type == RequestType.image || !filterOption.onlyLivePhotos,
'Filtering only Live Photos is only supported '
'when the request type contains image.',
);
}
final int count = await assetCountAsync;
if (end > count) {
end = count;
}
return plugin.getAssetListRange(
id,
type: type,
start: start,
end: end,
optionGroup: filterOption,
);
}