convertIterableFromNative method

dynamic convertIterableFromNative(
  1. dynamic value,
  2. Type serialType,
  3. IterableKind kind
)

Converts the value, which can be either a Iterable or instance of the type associated with serialType, depending on the IterableKind, to its native representation using the converter associated with serialType.

If the value is a Iterable implementation, it will converted to the desired IterableKind. Trying to convert singular values to an Iterable will result in an exception.

Implementation

dynamic convertIterableFromNative(dynamic value, Type serialType, IterableKind kind) {
  if (kind == IterableKind.none) {
    return convertObjectFromNative(value, serialType);
  } else if (value is! Iterable) {
    throw DogException("Cannot convert non-iterable value to iterable of type $serialType");
  }
  return adjustIterable(
    value.map((e) {
      return convertObjectFromNative(e, serialType);
    }),
    kind,
  );
}