fix response-counting logic

could be improved yet...
This commit is contained in:
Josh Babb 2023-07-27 15:32:18 -05:00
parent 1674c04020
commit 5f604eba3c

View file

@ -46,13 +46,16 @@ class LitescribeAPI {
'/address/inscriptions?address=$address&cursor=$cursor&size=$size');
// Check if the number of returned inscriptions equals the limit
final list = response.data['result']['list'];
final int total = response.data['result']['total'] as int;
int currentSize = 0;
if (list != null) {
currentSize = list.length as int;
if (total == 0) {
return <InscriptionData>[];
}
final list = response.data['result']!['list'];
currentSize = list.length as int;
if (currentSize == size && currentSize < total) {
// If the number of returned inscriptions equals the limit and there are more inscriptions available,
// increment the cursor and make the next API call to fetch the remaining inscriptions.