import 'attachment.dart'; class Post { final String added; final List attachments; final String content; final String edited; final String id; final String published; final String service; final String title; final String user; final String baseUrl; Post({ required this.added, required this.attachments, required this.content, required this.edited, required this.id, required this.published, required this.service, required this.title, required this.user, required this.baseUrl, }); List get mediaAttachments => attachments.where((a) => a.isImage || a.isVideo).toList(); factory Post.fromJson(Map json, String baseUrl) => Post( added: json['added'], attachments: List.from( json['attachments'].map((x) => Attachment.fromJson(x,baseUrl))), content: json['content'], edited: json['edited'] ?? "", id: json['id'], published: json['published'], service: json['service'], title: json['title'], user: json['user'], baseUrl: baseUrl, ); }