fromXmlString method Null safety

WebFeed fromXmlString(
  1. String xmlString
)

Implementation

static WebFeed fromXmlString(String xmlString) {
  final rssVersion = detectRssVersion(xmlString);
  switch (rssVersion) {
    case RssVersion.RSS1:
      final rss1Feed = Rss1Feed.parse(xmlString);
      return WebFeed.fromRss1(rss1Feed);
    case RssVersion.RSS2:
      final rss2Feed = RssFeed.parse(xmlString);
      return WebFeed.fromRss2(rss2Feed);
    case RssVersion.Atom:
      final atomFeed = AtomFeed.parse(xmlString);
      return WebFeed.fromAtom(atomFeed);
    case RssVersion.Unknown:
      throw Error.safeToString(
          'Invalid XML String? We cannot detect RSS/Atom version.');
    default:
      throw Exception('Some error has occured.');
  }
}