The Webfeed Flutter package for Appeto SDK.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

  1. import 'package:webfeedclient/domain/rss_category.dart';
  2. import 'package:webfeedclient/util/helpers.dart';
  3. import 'package:xml/xml.dart';
  4. class RssItem {
  5. final String title;
  6. final String description;
  7. final String link;
  8. final List<RssCategory> categories;
  9. final String guid;
  10. final String pubDate;
  11. RssItem(this.title, this.description, this.link, {this.categories, this.guid, this.pubDate});
  12. factory RssItem.parse(XmlElement element) {
  13. var title = xmlGetString(element, "title");
  14. var description = xmlGetString(element, "description");
  15. var link = xmlGetString(element, "link");
  16. List<RssCategory> categories = element.findElements("category").map((element) {
  17. return new RssCategory.parse(element);
  18. }).toList();
  19. var guid = xmlGetString(element, "guid", strict: false);
  20. var pubDate = xmlGetString(element, "pubDate", strict: false);
  21. return new RssItem(title, description, link, categories: categories, guid: guid, pubDate: pubDate);
  22. }
  23. @override
  24. String toString() {
  25. return '''
  26. title: $title
  27. description: $description
  28. link: $link
  29. pubDate: $pubDate
  30. ''';
  31. }
  32. }