findReader method

  1. @override
Deserializer? findReader(
  1. dynamic input,
  2. String targetType
)
override

Implementation

@override
Deserializer? findReader(final input, String targetType) {
  Match? match;
  if (input is List && (match = _listRegEx.firstMatch(targetType)) != null) {
    return (v) {
      final value = v as List;
      var newTargetType = match![1];
      return value
          .map((v) => findSingleReader(v, newTargetType)!(v))
          .toList();
    };
  } else if (input is Map &&
      (match = _mapRegEx.firstMatch(targetType)) != null) {
    return (v) {
      final value = v as Map;
      var newTargetType = match![1];
      return Map.fromIterables(
          value.keys,
          value.values
              .map((v) => (v) => findSingleReader(v, newTargetType)!(v)));
    };
  } else {
    return findSingleReader(input, targetType);
  }
}