1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import 'attachment.dart';
- class Post {
- final String added;
- final List<Attachment> 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<Attachment> get mediaAttachments =>
- attachments.where((a) => a.isImage || a.isVideo).toList();
- factory Post.fromJson(Map<String, dynamic> json, String baseUrl) => Post(
- added: json['added'],
- attachments: List<Attachment>.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,
- );
- }
|