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 {
List<Article> articles = snapshot.data;
return ListView.builder(
//shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: articles.length,
itemBuilder: (ctx, idx) {

View File

@@ -77,3 +77,31 @@ 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';
class sport_standings_football {
final int id; //id for each game
final DateTime date; //date: 2020-09-05T00:00:00
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
/*class sport_standings_football {
final int id;
final String displayName;
final String image;
// -- result json --
final String status; //status: W - T - L
final String team_score; //team_score:
final String opponent_score; //opponent_score:
final String postscore;
final String position;
// -- Conference stats --
final String conferenceRecord;
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(
this.id, {
this.date,
this.location_indicator,
this.location,
this.idSport,
this.sportTitle,
this.gender,
this.opponentTitle,
this.displayName,
this.image,
this.status,
this.team_score,
this.opponent_score,
this.postscore,
this.position,
this.conferenceRecord,
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) {
return sport_standings_football(
json['id'],
date: DateTime.parse(json['date']),
location_indicator: json['location_indicator'],
location: json['location'],
displayName: json['standings']['entries']['team']['displayName'],
image: json['standings']['entries']['team']['logos']['href'],
idSport: json['sport']['id'],
sportTitle: json['sport']['title'],
gender: json['sport']['gender'],
for (team in json['standings']['entries']) {
var stats = new Map<String, dynamic>();
for (stat in team['stats']) {
stats[stat['type']] = stat;
}
opponentTitle: json['opponent']['title'],
image: json['opponent']['image'],
var team_widget = basketball_widget(
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'],
postscore: json['result']['postscore'],
overallRecord: stats['total']['displayValue'],
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,7 +44,7 @@ class HorizontalStandings extends StatelessWidget {
return Center(
child: Column(
children: <Widget>[
//_buildBasketballStandings(),
if (globals.Sport.sport_ID.toString() == "5" || globals.Sport.sport_ID.toString() == "13") // M-W Basketball
Expanded(
child: FutureBuilder(
future: teamStandings.getTeams(),
@@ -52,29 +52,49 @@ class HorizontalStandings extends StatelessWidget {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
} else {
List<sport_standings_basketball> teams = snapshot.data;
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: snapshot.data.length,
itemBuilder: (ctx, idx) {
return DataTable(
columns: [
DataColumn(label: Text("")),
DataColumn(label: Text("Conference")),
DataColumn(label: Text("Overall")),
],
return StandingsCard(
team: teams[idx],
);
},
}
);
}
},
),
)
/*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 {
final int sportID;
Team_Standings(this.sportID);