addIfNonNull method

bool addIfNonNull(
  1. E? element
)

Adds the element to this list and returns true if it is not null.

[].addIfNonNull(1); // [1], true

[].addIfNonNull(null); // [], false

Implementation

bool addIfNonNull(E? element) {
  final result = element != null;
  if (result) {
    add(element);
  }
  return result;
}