Tuple1<T>.fromList constructor

Tuple1<T>.fromList(
  1. List list, [
  2. bool trim = false
])

Creates an tuple from a list source.

Implementation

factory Tuple1.fromList(List<dynamic> list, [bool trim = false]) {
  if (list.isEmpty) {
    throw ArgumentError.value(
        'list', 'The given list has less than 1 element.');
  }
  if (!trim && list.length > 1) {
    throw ArgumentError.value('list',
        'The given list has more than 1 element. Use `trim: true` if you intended to ignore excess elements.');
  }
  return Tuple1(list[0] as T);
}