Tuple2<T0, T1>.fromList constructor

Tuple2<T0, T1>.fromList(
  1. List list, [
  2. bool trim = false
])

Creates an tuple from a list source.

Implementation

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