NonEmptyList<T> constructor

NonEmptyList<T>(
  1. List<T> items
)

Constructs a NonEmptyList.

Throws an ArgumentError if the provided list is empty.

Implementation

NonEmptyList(List<T> items)
    : _items = items.isNotEmpty
          ? List.unmodifiable(items)
          : throw ArgumentError('List must not be empty');