listFromJson<T extends SchemaItem> function

List<T>? listFromJson<T extends SchemaItem>(
  1. dynamic json
)

Implementation

List<T>? listFromJson<T extends SchemaItem>(dynamic json) {
  if (json == null) {
    return null;
  }

  if (json is! List) {
    throw ArgumentError.value(json, 'json', 'is not a List');
  }

  return json.map((e) {
    final item = vyuh.content.fromJson<T>(e);
    assert(item != null,
        'Could not convert JSON to $T. You have missed setting a de-serializer for schemaType: "${vyuh.content.provider.schemaType(e)}".');

    return item!;
  }).toList(growable: false);
}