addIf method

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

Add item to List

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

Implementation

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