numOfCompleted function Null safety

dynamic numOfCompleted(
  1. List<int> listLengths,
  2. int index
)

Implementation

numOfCompleted(List<int> listLengths, int index) {
  index = index + 1;
  int val = 0;
  for (int i = 0; i < listLengths.length; i++) {
    if (listLengths[i] >= index) break;
    val = listLengths[i];
  }
  return (index - val);
}