insertWhere method
Inserts an insert element at the element's position if True with a test
.
Implementation
List<T> insertWhere(
T element, bool Function(T? prev, T? current, T? next) test) {
for (int i = length - 1; i >= 0; i--) {
if (!test(i <= 0 ? null : this[i - 1], this[i],
i >= length - 1 ? null : this[i + 1])) {
continue;
}
insert(i, element);
return this;
}
insert(0, element);
return this;
}