addIf method

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

Add item to List<E> only if condition is true.

Implementation

void addIf(dynamic condition, E item) {
  bool mergedCondition = false;
  if (condition is ConditionCallback) mergedCondition = condition();
  if (mergedCondition || (condition is bool && condition)) add(item);
}