Content.fromJson constructor
Content.fromJson(
- Map<String, dynamic> json
)
Implementation
factory Content.fromJson(Map<String, dynamic> json) {
List<CarouselItem>? carouselItems;
if ((json['type'] == 'carousel' || json['type'] == 'video') &&
json['carouselItems'] != null &&
json['carouselItems'].isNotEmpty) {
carouselItems = (json['carouselItems'] as List)
.map((item) => CarouselItem.fromJson(item))
.toList();
}
return Content(
type: json['type'],
data: json['data'],
carouselItems: carouselItems,
);
}