The Webfeed Flutter package for Appeto SDK.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

86 wiersze
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 = new RssContent.parse(element.findElements("content:encoded").first);
  47. } on StateError {}
  48. return new RssItem(
  49. title,
  50. description,
  51. link,
  52. categories: categories,
  53. guid: guid,
  54. pubDate: pubDate,
  55. author: author,
  56. comments: comments,
  57. source: source,
  58. content: content,
  59. );
  60. }
  61. @override
  62. String toString() {
  63. return '''
  64. title: $title
  65. description: $description
  66. link: $link
  67. guid: $guid
  68. pubDate: $pubDate
  69. author: $author
  70. comments: $comments
  71. source: $source
  72. content: $content
  73. ''';
  74. }
  75. }