The Webfeed Flutter package for Appeto SDK.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

58 строки
1.7 KiB

  1. import 'package:webfeed/domain/rss_category.dart';
  2. import 'package:webfeed/domain/rss_source.dart';
  3. import 'package:webfeed/util/helpers.dart';
  4. import 'package:xml/xml.dart';
  5. class RssItem {
  6. final String title;
  7. final String description;
  8. final String link;
  9. final List<RssCategory> categories;
  10. final String guid;
  11. final String pubDate;
  12. final String author;
  13. final String comments;
  14. final RssSource source;
  15. RssItem(this.title, this.description, this.link,
  16. {this.categories, this.guid, this.pubDate, this.author, this.comments, this.source});
  17. factory RssItem.parse(XmlElement element) {
  18. var title = xmlGetString(element, "title");
  19. var description = xmlGetString(element, "description");
  20. var link = xmlGetString(element, "link");
  21. var categories = element.findElements("category").map((element) {
  22. return new RssCategory.parse(element);
  23. }).toList();
  24. var guid = xmlGetString(element, "guid", strict: false);
  25. var pubDate = xmlGetString(element, "pubDate", strict: false);
  26. var author = xmlGetString(element, "author", strict: false);
  27. var comments = xmlGetString(element, "comments", strict: false);
  28. RssSource source;
  29. try {
  30. source = new RssSource.parse(element.findElements("source").first);
  31. } on StateError {}
  32. return new RssItem(title, description, link,
  33. categories: categories, guid: guid, pubDate: pubDate, author: author, comments: comments, source: source);
  34. }
  35. @override
  36. String toString() {
  37. return '''
  38. title: $title
  39. description: $description
  40. link: $link
  41. guid: $guid
  42. pubDate: $pubDate
  43. author: $author
  44. comments: $comments
  45. source: $source
  46. ''';
  47. }
  48. }