Bug fix, custom rss read error.

This commit is contained in:
stonega 2021-01-09 18:07:56 +08:00
parent e97752bea5
commit 98b6f2f829
1 changed files with 10 additions and 9 deletions

View File

@ -53,10 +53,11 @@ class MyHomePageDelegate extends SearchDelegate<int> {
RegExp rssExp = RegExp(r'^(https?):\/\/(.*)'); RegExp rssExp = RegExp(r'^(https?):\/\/(.*)');
Widget invalidRss(BuildContext context) => Container( Widget _invalidRss(BuildContext context) => Container(
height: 50, padding: EdgeInsets.only(top: 200),
alignment: Alignment.center, alignment: Alignment.topCenter,
child: Text(context.s.searchInvalidRss), child: Text(context.s.searchInvalidRss,
style: context.textTheme.headline6.copyWith(color: Colors.red)),
); );
@override @override
@ -196,7 +197,7 @@ class MyHomePageDelegate extends SearchDelegate<int> {
future: _getRss(rssExp.stringMatch(query)), future: _getRss(rssExp.stringMatch(query)),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasError) { if (snapshot.hasError) {
return invalidRss(context); return _invalidRss(context);
} else if (snapshot.hasData) { } else if (snapshot.hasData) {
return RssResult( return RssResult(
url: rssExp.stringMatch(query), url: rssExp.stringMatch(query),
@ -244,10 +245,10 @@ class _RssResultState extends State<RssResult> {
_loadItems = 10; _loadItems = 10;
_onlinePodcast = OnlinePodcast( _onlinePodcast = OnlinePodcast(
rss: widget.url, rss: widget.url,
title: p.title, title: p?.title ?? widget.url,
publisher: p.author, publisher: p?.author ?? "",
description: p.description, description: p?.description ?? "No description for this podcast",
image: p.itunes.image.href, image: p?.itunes?.image?.href ?? p?.image?.url ?? "",
count: p.items.length); count: p.items.length);
super.initState(); super.initState();
} }