addAllIf method

void addAllIf(
  1. dynamic condition,
  2. Iterable<E> items
)

Adds Iterable<E> to List<E> only if condition is true.

If condition is a boolean value and evaluates to true, items are added to the list.

Implementation

void addAllIf(condition, Iterable<E> items) {
  if (condition is Condition) {
    condition = condition();
  }
  if (condition is bool && condition) {
    addAll(items);
  }
}