addToList static method
Adds an element to the list Adding must be in the correct order, so if the list is too small, then it won't be added Returns true, if the element was added
Implementation
static bool addToList({
required List list,
required int index,
required dynamic element,
required bool overwrite,
}) {
if (index <= list.length) {
if (index == list.length) {
list.add(element);
} else if (overwrite) {
list[index] = element;
}
return true;
} else {
return false;
}
}