normalizeIDs method

List? normalizeIDs(
  1. Iterable? ids, {
  2. O? obj,
})

Implementation

List? normalizeIDs(Iterable? ids, {O? obj}) {
  if (ids == null) return null;

  var idType = this.idType(obj);

  if (idType == int) {
    if (ids is List<int?>) {
      return ids;
    } else if (ids is Iterable<int?>) {
      return ids.toList();
    }

    return ids.map(TypeParser.parseInt).toList();
  } else if (idType == String) {
    if (ids is List<String?>) {
      return ids;
    } else if (ids is Iterable<String?>) {
      return ids.toList();
    }

    return ids.map(TypeParser.parseString).toList();
  } else {
    var idParser = TypeParser.parserFor(type: idType);
    return idParser == null ? ids.toList() : ids.map(idParser).toList();
  }
}