import 'package:didvan/models/content.dart'; import 'package:didvan/models/tag.dart'; class NewsDetailsData { final int id; final String title; final String reference; final String image; final String createdAt; final bool marked; final int comments; final List tags; final List contents; const NewsDetailsData({ required this.id, required this.title, required this.reference, required this.image, required this.createdAt, required this.marked, required this.comments, required this.tags, required this.contents, }); factory NewsDetailsData.fromJson(Map json) { return NewsDetailsData( id: json['id'], title: json['title'], reference: json['reference'], image: json['image'], createdAt: json['createdAt'], marked: json['marked'], comments: json['comments'], tags: List.from(json['tags'].map((tag) => Tag.fromJson(tag))), contents: List.from(json['contents'].map( (content) => Content.fromJson(content), )), ); } Map toJson() => { 'id': id, 'title': title, 'reference': reference, 'image': image, 'createdAt': createdAt, 'marked': marked, 'comments': comments, 'tags': tags.map((e) => e.toJson()).toList(), 'contents': contents.map((e) => e.toJson()).toList(), }; }