diff --git a/lib/home/home_groups.dart b/lib/home/home_groups.dart index 5381f41..5ebf2e0 100644 --- a/lib/home/home_groups.dart +++ b/lib/home/home_groups.dart @@ -471,19 +471,33 @@ class _ScrollPodcastsState extends State } } -class PodcastPreview extends StatelessWidget { +class PodcastPreview extends StatefulWidget { final PodcastLocal podcastLocal; + PodcastPreview({this.podcastLocal, Key key}) : super(key: key); + @override + _PodcastPreviewState createState() => _PodcastPreviewState(); +} + +class _PodcastPreviewState extends State { + Future _getRssItem; + Future> _getRssItemTop(PodcastLocal podcastLocal) async { var dbHelper = DBHelper(); var episodes = await dbHelper.getRssItemTop(podcastLocal.id); return episodes; } + @override + void initState() { + super.initState(); + _getRssItem = _getRssItemTop(widget.podcastLocal); + } + @override Widget build(BuildContext context) { - final c = podcastLocal.backgroudColor(context); + final c = widget.podcastLocal.backgroudColor(context); return Column( children: [ Expanded( @@ -491,12 +505,12 @@ class PodcastPreview extends StatelessWidget { selector: (_, worker) => worker.created, builder: (context, created, child) { return FutureBuilder>( - future: _getRssItemTop(podcastLocal), + future: _getRssItem, builder: (context, snapshot) { return (snapshot.hasData) ? ShowEpisode( episodes: snapshot.data, - podcastLocal: podcastLocal, + podcastLocal: widget.podcastLocal, ) : Padding( padding: const EdgeInsets.all(5.0), @@ -514,7 +528,7 @@ class PodcastPreview extends StatelessWidget { children: [ Expanded( flex: 4, - child: Text(podcastLocal.title, + child: Text(widget.podcastLocal.title, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontWeight: FontWeight.bold, color: c)),