getAssetListRange method Null safety

Future<List<AssetEntity>> getAssetListRange(
  1. {required int start,
  2. required int end}
)

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.');
  assert(
    type == RequestType.image || !filterOption.onlyLivePhotos,
    'Filtering only Live Photos is only supported '
    'when the request type contains image.',
  );
  if (end > assetCount) {
    end = assetCount;
  }
  return plugin.getAssetListRange(
    id,
    type: type,
    start: start,
    end: end,
    optionGroup: filterOption,
  );
}