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.

26 line
633 B

  1. import 'dart:async';
  2. import 'package:http/http.dart' as http;
  3. import 'package:webfeedclient/domain/rss_feed.dart';
  4. import 'package:xml/xml.dart' as xml;
  5. class WebFeedClient {
  6. http.Client client;
  7. WebFeedClient() {
  8. client = new http.Client();
  9. }
  10. Future<RssFeed> fetch(String url) {
  11. return client.get(url).then((response) {
  12. print("Response Status Code: ${response.statusCode}");
  13. print("Response Body: ${response.body}");
  14. return response.body;
  15. }).then((bodyString) {
  16. var document = xml.parse(bodyString);
  17. var channel = new RssFeed.parse(document);
  18. return channel;
  19. });
  20. }
  21. }