firstWhereOrAdd<V> function
Returns the first element that satisfies the test if there isn't one add a new one and return it.
Implementation
V firstWhereOrAdd<V>(
List<V> list, bool Function(V element) test, OrAdd<V> orAdd) {
for (final V element in list) {
if (test(element)) return element;
}
V newElement = orAdd();
list.add(newElement);
return newElement;
}