toPair<R> method

R? toPair<R>(
  1. dynamic pair,
  2. PairMapper<R, X?, Y?> typeWrapper
)

Implementation

R? toPair<R>(dynamic pair, PairMapper<R, X?, Y?> typeWrapper) {
  if (pair == null) return null;

  dynamic a, b;

  if (pair is List) {
    a = pair[0];
    b = pair[1];
  } else if (pair is Map) {
    a = findKeyValue(pair, ['x', 'a', 'time', 't', 'date', 'key', 'k'], true);
    b = findKeyValue(pair, ['y', 'b', 'value', 'val', 'v'], true);
  } else if (pair is Pair) {
    a = pair.a;
    b = pair.b;
  } else if (pair is String) {
    var split = pair.split(stringPairDelimiterPattern);
    a = split[0].trim();
    b = split[1].trim();
  } else {
    return null;
  }

  return toPairImpl(a, b, typeWrapper);
}