addIf method

void addIf (
  1. dynamic condition,
  2. E element
)

Adds element only if condition resolves to true.

Implementation

void addIf(/* bool | Condition */ condition, E element) {
  if (condition is Condition) condition = condition();
  if (condition is bool && condition) add(element);
}