addIf method

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

Adds item only if condition resolves to true.

Implementation

void addIf(dynamic condition, E item) {
  if (condition is Condition) condition = condition();
  if (condition is bool && condition) add(item);
}