post.dart 905 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'attachment.dart';
  2. class Post {
  3. final String added;
  4. final List<Attachment> attachments;
  5. final String content;
  6. final String edited;
  7. final String id;
  8. final String published;
  9. final String service;
  10. final String title;
  11. final String user;
  12. Post({
  13. required this.added,
  14. required this.attachments,
  15. required this.content,
  16. required this.edited,
  17. required this.id,
  18. required this.published,
  19. required this.service,
  20. required this.title,
  21. required this.user,
  22. });
  23. factory Post.fromJson(Map<String, dynamic> json) => Post(
  24. added: json['added'],
  25. attachments: List<Attachment>.from(
  26. json['attachments'].map((x) => Attachment.fromJson(x))),
  27. content: json['content'],
  28. edited: json['edited'] ?? "",
  29. id: json['id'],
  30. published: json['published'],
  31. service: json['service'],
  32. title: json['title'],
  33. user: json['user'],
  34. );
  35. }