ifEmpty<T> function Null safety

List<T?> ifEmpty<T>(
  1. Iterable<T>? list,
  2. {T? then}
)

Implementation

List<T?> ifEmpty<T>(Iterable<T>? list, {T? then}) => [
      ...?list,
      if (list?.isNotEmpty != true) then,
    ];