Standings - No table currently / Future Builder works but has an error (RenderFlex children have non-zero flex but incoming height constraints are unbounded.)

This commit is contained in:
kconnel7
2020-04-30 10:50:35 -04:00
parent b02efa9cc8
commit 4d66b774fb
4 changed files with 182 additions and 69 deletions

View File

@@ -61,6 +61,7 @@ class HorizontalNewsFeed extends StatelessWidget {
} else { } else {
List<Article> articles = snapshot.data; List<Article> articles = snapshot.data;
return ListView.builder( return ListView.builder(
//shrinkWrap: true,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: articles.length, itemCount: articles.length,
itemBuilder: (ctx, idx) { itemBuilder: (ctx, idx) {

View File

@@ -76,4 +76,32 @@ class sport_standings_basketball {
}*/ }*/
); );
} }
}
class StandingsCard extends StatelessWidget {
const StandingsCard({
Key key,
@required this.team,
}) : super(key: key);
final sport_standings_basketball team;
@override
Widget build(BuildContext context) {
return Expanded(
child: Card(
child: ListTile(
leading: Image.network(
team.image,
width: 35.0,
),
title: Text(
team.displayName,
),
//decoration: decoration,
//child: body,
),
),
);
}
} }

View File

@@ -1,64 +1,128 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class sport_standings_football { /*class sport_standings_football {
final int id; //id for each game final int id;
final DateTime date; //date: 2020-09-05T00:00:00 final String displayName;
final String location_indicator; //location_indicator: H-Home / A-Away
final String location; //location: Knoxville, Tenn., Charlotte, NC
// -- sport json --
final int idSport; //id: Each sport different number
final String sportTitle; //title: Football, Men's Soccer
final String gender; //gender: M - F
// -- opponent json --
final String opponentTitle; //title: Tennessee, Norfolk State
final String image; final String image;
// -- result json -- final String position;
final String status; //status: W - T - L
final String team_score; //team_score: // -- Conference stats --
final String opponent_score; //opponent_score: final String conferenceRecord;
final String postscore; final String gamesBehind;
final String conferencePercentRecord;
// -- Overall stats --
final String overallRecord;
final String overallPercentRecord;
final String homeRecord;
final String awayRecord;
final String gameStreak;
// -- Polls stats --
final String apRecord;
final String usaRecord;
sport_standings_football( sport_standings_football(
this.id, { this.id, {
this.date, this.displayName,
this.location_indicator,
this.location,
this.idSport,
this.sportTitle,
this.gender,
this.opponentTitle,
this.image, this.image,
this.status, this.position,
this.team_score,
this.opponent_score, this.conferenceRecord,
this.postscore, this.gamesBehind,
this.conferencePercentRecord,
this.overallRecord,
this.overallPercentRecord,
this.homeRecord,
this.awayRecord,
this.gameStreak,
this.apRecord,
this.usaRecord,
}); });
factory sport_standings_football.fromJson(Map<String, dynamic> json) { factory sport_standings_football.fromJson(Map<String, dynamic> json) {
return sport_standings_football( return sport_standings_football(
json['id'], json['id'],
date: DateTime.parse(json['date']), displayName: json['standings']['entries']['team']['displayName'],
location_indicator: json['location_indicator'], image: json['standings']['entries']['team']['logos']['href'],
location: json['location'],
idSport: json['sport']['id'], for (team in json['standings']['entries']) {
sportTitle: json['sport']['title'], var stats = new Map<String, dynamic>();
gender: json['sport']['gender'], for (stat in team['stats']) {
stats[stat['type']] = stat;
}
opponentTitle: json['opponent']['title'], var team_widget = basketball_widget(
image: json['opponent']['image'], position: stats['playoffseed']['displayValue'],
status: json['result']['status'], conferenceRecord: stats['vsconf']['displayValue'],
gamesBehind: stats['vsconf_gamesbehind']['displayValue'],
conferencePercentRecord: stats['vsconf_winpercent']['displayValue'],
team_score: json['result']['team_score'],
opponent_score: json['result']['opponent_score'], overallRecord: stats['total']['displayValue'],
postscore: json['result']['postscore'], overallPercentRecord: stats['winpercent']['displayValue'],
homeRecord: stats['home']['displayValue'],
awayRecord: stats['road']['displayValue'],
gameStreak: stats['streak']['displayValue'],
//apRecord: json['standings']['entries']['stats']['displayValue'],
//usaRecord: json['standings']['entries']['stats']['displayValue'],
)
}
); );
} }
} }
class StandingsCard extends StatelessWidget {
const StandingsCard({
Key key,
@required this.team,
}) : super(key: key);
final sport_standings_football team;
@override
Widget build(BuildContext context) {
var decoration = BoxDecoration(
image: DecorationImage(
image: NetworkImage(
team.image,
),
),
);
var body = Column(
verticalDirection: VerticalDirection.up,
children: <Widget>[
Container(
child: ListTile(
title: Text(
team.displayName,
),
),
),
],
);
return Expanded(
child: Card(
child: ListTile(
leading: Image.network(
team.image,
width: 35.0,
),
title: Text(
team.displayName,
),
//decoration: decoration,
//child: body,
),
),
);
}
}*/

View File

@@ -44,37 +44,57 @@ class HorizontalStandings extends StatelessWidget {
return Center( return Center(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
//_buildBasketballStandings(), if (globals.Sport.sport_ID.toString() == "5" || globals.Sport.sport_ID.toString() == "13") // M-W Basketball
Expanded( Expanded(
child: FutureBuilder( child: FutureBuilder(
future: teamStandings.getTeams(), future: teamStandings.getTeams(),
builder: (ctx, snapshot) { builder: (ctx, snapshot) {
if (!snapshot.hasData) { if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator()); return Center(child: CircularProgressIndicator());
} else { } else {
return ListView.builder( List<sport_standings_basketball> teams = snapshot.data;
scrollDirection: Axis.horizontal, return ListView.builder(
itemCount: snapshot.data.length, scrollDirection: Axis.horizontal,
itemBuilder: (ctx, idx) { itemCount: snapshot.data.length,
return DataTable( itemBuilder: (ctx, idx) {
columns: [ return StandingsCard(
DataColumn(label: Text("")), team: teams[idx],
DataColumn(label: Text("Conference")), );
DataColumn(label: Text("Overall")), }
], );
); }
}, },
); ),
} )
}, /*else if (globals.Sport.sport_ID.toString() == "3") // Football
), Expanded(
), child: FutureBuilder(
future: teamStandings.getTeams(),
builder: (ctx, snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
} else {
List<sport_standings_football> teams = snapshot.data;
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: snapshot.data.length,
itemBuilder: (ctx, idx) {
return StandingsCard(
team: teams[idx],
);
}
);
}
},
),
),*/
], ],
), ),
); );
} }
} }
//Delete later (not used)
/*class Team_Standings extends StatefulWidget { /*class Team_Standings extends StatefulWidget {
final int sportID; final int sportID;
Team_Standings(this.sportID); Team_Standings(this.sportID);