read2<T1, T2> method

Future<(T1, T2)> read2<T1, T2>()

Implementation

Future<(T1, T2)> read2<T1, T2>() async {
  final parts = await readList();
  final minLength = null is T1
      ? 0
      : null is T2
          ? 1
          : 2;
  if (parts.length < minLength) throw EOF();

  switch (parts.length) {
    case >= 2:
      return (
        _nonNullableParse<T1>(parts[0]),
        _nonNullableParse<T2>(parts[1]),
      );
    case == 1:
      return (
        _nonNullableParse<T1>(parts[0]),
        null as T2,
      );
    default:
      return (null as T1, null as T2);
  }
}