Quantcast
Channel: Flutter - Get image from RSS feed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Flutter - Get image from RSS feed

$
0
0

I am trying to get the image URL from this feed:

<item><title>Tuborg Classic er ikke en pilsner</title><link>https://durst.nu/2020/05/14/tuborg-classic-er-ikke-en-pilsner/</link><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">https://durst.nu/2020/05/14/tuborg-classic-er-ikke-en-pilsner/feed/</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://2.gravatar.com/avatar/b36123a06ead4213d98787e5913b6eb7?s=96&d=identicon&r=G" medium="image"><media:title type="html">chrcph</media:title></media:content><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=566" medium="image"/><description>Som pilsner ekspert er det ok at være en pedant, ikke? Pille løs i stort og småt. Være træls. På tværs. Tæt på ulidelig. Det er vel nærmest forventeligt, når man har skrevet en grundbog om pilsner, &#8220;Den nøgne øl&#8221; &#8230; <a href="https://durst.nu/2020/05/14/tuborg-classic-er-ikke-en-pilsner/">Continue reading <span class="meta-nav">&#8594;</span></a></description><content:encoded><figure class="wp-block-image size-large"><img data-attachment-id="2192" data-permalink="https://durst.nu/tuborg-classic/" data-orig-file="https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg" data-orig-size="1934,3500" data-comments-opened="1" data-image-meta="{&#34;aperture&#34;:&#34;0&#34;,&#34;credit&#34;:&#34;&#34;,&#34;camera&#34;:&#34;&#34;,&#34;caption&#34;:&#34;&#34;,&#34;created_timestamp&#34;:&#34;0&#34;,&#34;copyright&#34;:&#34;&#34;,&#34;focal_length&#34;:&#34;0&#34;,&#34;iso&#34;:&#34;0&#34;,&#34;shutter_speed&#34;:&#34;0&#34;,&#34;title&#34;:&#34;&#34;,&#34;orientation&#34;:&#34;0&#34;}" data-image-title="tuborg-classic" data-image-description="" data-medium-file="https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=166" data-large-file="https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=566" src="https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=566" alt="" class="wp-image-2192" srcset="https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=566 566w, https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=1132 1132w, https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=83 83w, https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=166 166w, https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=768 768w" sizes="(max-width: 566px) 100vw, 566px" /></figure> <p>Som pilsner ekspert er det ok at være en pedant, ikke?</p> <p>Pille løs i stort og småt. Være træls. På tværs. Tæt på ulidelig.</p> <p>Det er vel nærmest forventeligt, når man har skrevet en grundbog om pilsner, &#8220;Den nøgne øl&#8221; på 380 sider.</p> <p>Tag nu goe gamle Tuborg Classic.&#160;</p> <p>En &#8220;traditionel pilsner&#8221; står der på etiketten &#8211; og med &#8220;frisk og fyldig pilsnersmag&#8221;.</p> <p>Nej, Tuborg Classic er ikke en pilsner.&#160;</p> <p>Det er nok nærmere en wienerøl. </p> <p>Wienerøl er &#8211; modsat classic-betegnelsen &#8211; en certificeret øltype. </p> <p>Jeg er med på, at der var stilforvirring blandt de ølkyndige i 1993, da Tuborg Classic blev lanceret. Fx ingen Beer Judge Certification Program, men hvis folkene fra markedsføringsafdelingen havde rådført sig med en kyndig brygmester, pilsner brygger, inden lanceringen, kom der næppe til at stå&#8216;traditionel pilsner&#8217; på Tuborg Classic.</p> <p>Hos Beer Judge Certification Program (BJCP), det højeste organ for certificering af øl, har wienerøl en selvstændig kategori, Vienna Lager (7A).&#160;</p> <p>Men måske Tuborg Classic skal placeres i en lidt anden kategori hos BJCP, for Tuborg Classic er jo industribryg og så får kategorien præfixet &#8220;international&#8221; hos BJCP.&#160;</p> <p>Så den rette kategori for Tuborg Classic er nok International Amber Lager (2B).</p> <p>Ih, sjovt at være træls.</p> <p></p></content:encoded><category>Uncategorized</category><category>classic</category><category>pilsner</category><category>Tuborg</category><pubDate>Thu, 14 May 2020 07:02:30 GMT</pubDate><comments>https://durst.nu/2020/05/14/tuborg-classic-er-ikke-en-pilsner/#respond</comments><guid isPermaLink="false">http://durst.nu/?p=2191</guid><dc:creator>chrcph</dc:creator><dc:date>2020-05-14T07:02:30Z</dc:date></item><item>

I am getting the title and description from the feed, but I have truble to get the image - - Below are my Flutter code. Please note that there are 2 Media content - How do I get this URL https://chrcph.files.wordpress.com/2020/05/tuborg-classic.jpg?w=566 from the feed into Flutter ?

import 'package:flutter/material.dart';import 'package:webfeed/webfeed.dart';import 'package:http/http.dart' as http;import 'package:url_launcher/url_launcher.dart';import 'package:cached_network_image/cached_network_image.dart';class News extends StatefulWidget {  News() : super ();  final String title = 'Rss feed Demo';  @override  _NewsState createState() => _NewsState();}class _NewsState extends State<News> {  //static const String FEED_URL = 'https://www.nasa.gov/rss/dyn/lg_image_of_the_day.rss';  static const String FEED_URL = 'http://www.rssmix.com/u/11631847/rss.xml';  RssFeed _feed;  String _title;  static const String loadingFeedMsg = 'Loading feed....';  static const String feedLoadErrorMsg = 'Error loading feed';  static const String feedOpenErrorMsg = 'Error opening Feed';  static const String placeholderImg = 'images/no_image.png';  GlobalKey<RefreshIndicatorState> _refreshKey;  updateTitle(title){    setState(() {      _title = title;    });  }  updateFeed(feed){    setState(() {      _feed = feed;    });  }  Future<void> openFeed(String url) async {    if(await canLaunch((url))){      await launch(url, forceSafariVC: true, forceWebView: false,      );      return;    }    updateTitle(feedOpenErrorMsg);  }  load() async {    updateTitle(loadingFeedMsg);    loadFeed().then((result){      if(null == result ||result.toString().isEmpty){        updateTitle(feedLoadErrorMsg);        return;      }      updateFeed(result);      updateTitle(_feed.title);    });  }  Future<RssFeed> loadFeed() async{    try{      final client = http.Client();      final response = await client.get(FEED_URL);      return RssFeed.parse(response.body);    }catch (e){      return null;    }  }  @override  void initState() {    super.initState();    _refreshKey = GlobalKey<RefreshIndicatorState>();    updateTitle(widget.title);    load();  }  title(title){    return Text(      title,      style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w500),      maxLines: 2,        overflow: TextOverflow.ellipsis,    );  }  subtitle(subtitle){    return Text(      subtitle,      style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w200),      maxLines: 1,      overflow: TextOverflow.ellipsis,    );  }  thumbnail(imageUrl){    return Padding(      padding: EdgeInsets.only(left: 15.0),      child: CachedNetworkImage(        placeholder: (context, url) => Image.asset(placeholderImg),        imageUrl: imageUrl,        height: 50,        width: 70,        alignment: Alignment.center,        fit: BoxFit.fill,      ),    );  }  rightIcon(){    return Icon(      Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0,    );  }  list(){    return ListView.builder(      itemCount: _feed.items.length,      itemBuilder: (BuildContext context, int index){        final item = _feed.items[index];        return ListTile(         title: title(item.title),          subtitle: subtitle(item.description),          leading: thumbnail(item.media.content.url),          trailing: rightIcon(),          contentPadding: EdgeInsets.all(5.0),          onTap: () => openFeed(item.link),        );      },    );  }  isFeedEmpty(){    return null == _feed || null == _feed.items;  }  body(){    return isFeedEmpty() ? Center(      child: CircularProgressIndicator(),    )    :RefreshIndicator(      key: _refreshKey,      child: list(),      onRefresh: () => load(),    );  }  @override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(        title: Text(_title),      ),      body:  body(),    );  }}```

Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>