Tuple4<T0, T1, T2, T3>.fromList constructor

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

Creates an tuple from a list source.

Implementation

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