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.

87 lignes
2.1 KiB

  1. import 'package:webfeed/domain/rss_category.dart';
  2. import 'package:webfeed/domain/rss_content.dart';
  3. import 'package:webfeed/domain/rss_source.dart';
  4. import 'package:webfeed/util/helpers.dart';
  5. import 'package:xml/xml.dart';
  6. class RssItem {
  7. final String title;
  8. final String description;
  9. final String link;
  10. final List<RssCategory> categories;
  11. final String guid;
  12. final String pubDate;
  13. final String author;
  14. final String comments;
  15. final RssSource source;
  16. final RssContent content;
  17. RssItem(
  18. this.title,
  19. this.description,
  20. this.link, {
  21. this.categories,
  22. this.guid,
  23. this.pubDate,
  24. this.author,
  25. this.comments,
  26. this.source,
  27. this.content,
  28. });
  29. factory RssItem.parse(XmlElement element) {
  30. var title = xmlGetString(element, "title");
  31. var description = xmlGetString(element, "description", strict: false);
  32. var link = xmlGetString(element, "link", strict: false);
  33. var categories = element.findElements("category").map((element) {
  34. return new RssCategory.parse(element);
  35. }).toList();
  36. var guid = xmlGetString(element, "guid", strict: false);
  37. var pubDate = xmlGetString(element, "pubDate", strict: false);
  38. var author = xmlGetString(element, "author", strict: false);
  39. var comments = xmlGetString(element, "comments", strict: false);
  40. RssSource source;
  41. try {
  42. source = new RssSource.parse(element.findElements("source").first);
  43. } on StateError {}
  44. RssContent content;
  45. try {
  46. content =
  47. new RssContent.parse(element.findElements("content:encoded").first);
  48. } on StateError {}
  49. return new RssItem(
  50. title,
  51. description,
  52. link,
  53. categories: categories,
  54. guid: guid,
  55. pubDate: pubDate,
  56. author: author,
  57. comments: comments,
  58. source: source,
  59. content: content,
  60. );
  61. }
  62. @override
  63. String toString() {
  64. return '''
  65. title: $title
  66. description: $description
  67. link: $link
  68. guid: $guid
  69. pubDate: $pubDate
  70. author: $author
  71. comments: $comments
  72. source: $source
  73. content: $content
  74. ''';
  75. }
  76. }