import 'package:didvan/models/category.dart'; class ItemOverview { final int id; final String title; final String image; final String description; final int? timeToRead; final String? reference; final bool? forManagers; final String createdAt; final String? type; final List? categories; int? comments; ItemOverview({ required this.id, required this.title, required this.image, required this.description, required this.timeToRead, required this.reference, required this.forManagers, required this.createdAt, required this.type, required this.categories, required this.comments, }); factory ItemOverview.fromJson(Map json) => ItemOverview( id: json['id'], title: json['title'], image: json['image'], description: json['description'], timeToRead: json['timeToRead'], reference: json['reference'], forManagers: json['forManagers'], createdAt: json['createdAt'], type: json['type'], comments: json['comments'], categories: json['categories'] == null ? null : List.from( json['categories'].map( (cat) => Category.fromJson(cat), ), ), ); Map toJson() => { 'id': id, 'title': title, 'image': image, 'description': description, 'timeToRead': timeToRead, 'reference': reference, 'forManagers': forManagers, 'createdAt': createdAt, 'type': type, 'categories': categories?.map((e) => e.toJson()).toList(), }; }