loadImage method

int loadImage(
  1. String storageKey,
  2. int listLength
)

Implementation

int loadImage(String storageKey, int listLength) {
int storedIndex = Requests.box.read(storageKey) ?? 0;
int currentIndex = storedIndex;

if (storedIndex >= listLength - 1) {
  storedIndex = 0;
} else {
  storedIndex += 1;
}

Requests.box.write(storageKey, storedIndex);
return currentIndex;
}