listSetter function

dynamic listSetter(
  1. List list,
  2. int idx,
  3. dynamic value
)

Implementation

listSetter(List list, int idx, dynamic value) {
  if (list.length > idx) {
    list[idx] = value;
  } else if (list.length == idx) {
    list.add(value);
  } else {
    list.addAll(List<num>.filled(idx + 1 - list.length, 0));
    list[idx] = value;
  }
}