maybeAddToList<T> function

List<T>? maybeAddToList<T>(
  1. List<T>? source,
  2. List<T>? add
)

Adds add to source if both are not null.

Implementation

List<T>? maybeAddToList<T>(List<T>? source, List<T>? add) {
  if (source == null) return source;
  if (add == null) return source;
  return [...source, ...add];
}