filter article list to only contain correct sports

This commit is contained in:
2020-04-30 17:18:15 -04:00
parent d8de898a5a
commit 79886504ae
4 changed files with 18 additions and 15 deletions

View File

@@ -20,11 +20,13 @@ class HorizontalNewsFeed extends StatelessWidget {
final Feed newsFeed;
final Text title;
final double numCards;
final String sportFilter;
const HorizontalNewsFeed({
Key key,
@required this.newsFeed,
@required this.title,
@required this.sportFilter,
this.numCards = 3.25,
}) : super(key: key);
@@ -33,7 +35,8 @@ class HorizontalNewsFeed extends StatelessWidget {
}
@override
Widget build(BuildContext context) {
//print(title.data);
var page = newsFeed.getPage(1, size: 100).then((page) => page.where((article) => article.sport.toLowerCase().contains(sportFilter.toLowerCase())).toList());
return SizedBox(
height: heightIn(context),
child: Column(
@@ -55,7 +58,7 @@ class HorizontalNewsFeed extends StatelessWidget {
),
Expanded(
child: FutureBuilder(
future: newsFeed.getPage(1),
future: page,
builder: (ctx, snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());

View File

@@ -10,7 +10,6 @@ class Favorites {
'Basketball',
'Baseball',
'Soccer',
'Tennis',
'Volleyball'
];

View File

@@ -96,6 +96,7 @@ Future<List<HorizontalNewsFeed>> _buildList() async {
return HorizontalNewsFeed(
newsFeed: feed,
title: Text(sport),
sportFilter: sport,
);
}).toList();
}