The Webfeed Flutter package for Appeto SDK.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

95 lignes
2.5 KiB

  1. import 'package:webfeed/domain/atom_category.dart';
  2. import 'package:webfeed/domain/atom_link.dart';
  3. import 'package:webfeed/domain/atom_person.dart';
  4. import 'package:webfeed/domain/atom_source.dart';
  5. import 'package:webfeed/util/helpers.dart';
  6. import 'package:xml/xml.dart';
  7. class AtomItem {
  8. String id;
  9. String title;
  10. String updated;
  11. List<AtomPerson> authors;
  12. List<AtomLink> links;
  13. List<AtomCategory> categories;
  14. List<AtomPerson> contributors;
  15. AtomSource source;
  16. String published;
  17. String content;
  18. String summary;
  19. String rights;
  20. AtomItem(this.id, this.title, this.updated,
  21. {this.authors,
  22. this.links,
  23. this.categories,
  24. this.contributors,
  25. this.source,
  26. this.published,
  27. this.content,
  28. this.summary,
  29. this.rights});
  30. factory AtomItem.parse(XmlElement element) {
  31. var id = xmlGetString(element, "id");
  32. var title = xmlGetString(element, "title");
  33. var updated = xmlGetString(element, "updated");
  34. var authors = element.findElements("author").map((element) {
  35. return new AtomPerson.parse(element);
  36. }).toList();
  37. var links = element.findElements("link").map((element) {
  38. return new AtomLink.parse(element);
  39. }).toList();
  40. var categories = element.findElements("category").map((element) {
  41. return new AtomCategory.parse(element);
  42. }).toList();
  43. var contributors = element.findElements("contributor").map((element) {
  44. return new AtomPerson.parse(element);
  45. }).toList();
  46. AtomSource source;
  47. try {
  48. source = new AtomSource.parse(element.findElements("source").first);
  49. } on StateError {}
  50. var published = xmlGetString(element, "published", strict: false);
  51. var content = xmlGetString(element, "content", strict: false);
  52. var summary = xmlGetString(element, "summary", strict: false);
  53. var rights = xmlGetString(element, "rights", strict: false);
  54. return new AtomItem(id, title, updated,
  55. authors: authors,
  56. links: links,
  57. categories: categories,
  58. contributors: contributors,
  59. source: source,
  60. published: published,
  61. content: content,
  62. summary: summary,
  63. rights: rights);
  64. }
  65. @override
  66. String toString() {
  67. return '''
  68. id: $id
  69. title: $title
  70. updated: $updated
  71. authors: $authors
  72. links: $links
  73. categories: $categories
  74. contributors: $contributors
  75. source: $source
  76. published: $published
  77. content: $content
  78. summary: $summary
  79. rights: $rights
  80. ''';
  81. }
  82. }