File tree Expand file tree Collapse file tree 6 files changed +62
-36
lines changed Expand file tree Collapse file tree 6 files changed +62
-36
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,25 @@ import 'package:arena/views/stats_screen/goal_averages.dart';
10
10
import 'package:arena/views/stats_screen/scorers.dart' ;
11
11
12
12
class StatsScreen extends StatelessWidget {
13
- Widget get _extraInfo {
13
+ Widget _extraInfo (comparison) {
14
14
return Container (
15
15
color: Colors .white,
16
16
padding: EdgeInsets .symmetric (horizontal: 32 , vertical: 8 ),
17
17
child: Column (
18
18
children: [
19
- PreviousGamesView (),
19
+ PreviousGamesView (
20
+ homeTeamGames:
21
+ comparison != null ? comparison[0 ]['latest_games' ] : [],
22
+ oppTeamGames:
23
+ comparison != null ? comparison[1 ]['latest_games' ] : [],
24
+ ),
20
25
Divider (thickness: 2.0 ),
21
26
GoalAverages (),
22
27
Divider (thickness: 2.0 ),
23
- Scorers (),
28
+ Scorers (
29
+ homeGoalie: comparison[0 ]['goalie' ],
30
+ oppGoalie: comparison[1 ]['goalie' ],
31
+ ),
24
32
],
25
33
),
26
34
);
@@ -36,8 +44,9 @@ class StatsScreen extends StatelessWidget {
36
44
child: Column (
37
45
children: [
38
46
InformationListView (),
39
- ComparisonView (comparison: result.data['compareTeams' ]),
40
- _extraInfo,
47
+ if (result.data != null )
48
+ ComparisonView (comparison: result.data['compareTeams' ]),
49
+ if (result.data != null ) _extraInfo (result? .data['compareTeams' ]),
41
50
SizedBox (height: 16 ),
42
51
],
43
52
),
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ class ComparisonView extends StatelessWidget {
10
10
Container (
11
11
height: 50 ,
12
12
width: 50 ,
13
- child: Image .network (comparison[which]['logo' ]),
13
+ child: comparison != null
14
+ ? Image .network (comparison[which]['logo' ])
15
+ : null ,
14
16
),
15
17
SizedBox (height: 8 ),
16
18
],
@@ -52,10 +54,12 @@ class ComparisonView extends StatelessWidget {
52
54
width: 'Position in League' .length * 8.0 ,
53
55
child: Row (
54
56
mainAxisAlignment: MainAxisAlignment .spaceBetween,
55
- children: [
56
- Text ('${comparison [0 ]['rank' ]}' ),
57
- Text ('${comparison [1 ]['rank' ]}' )
58
- ],
57
+ children: comparison != null
58
+ ? [
59
+ Text ('${comparison [0 ]['rank' ]}' ),
60
+ Text ('${comparison [1 ]['rank' ]}' )
61
+ ]
62
+ : null ,
59
63
),
60
64
),
61
65
Text (
Original file line number Diff line number Diff line change @@ -5,8 +5,13 @@ import 'package:arena/widgets/previous_game.dart';
5
5
class PreviousGamesView extends StatelessWidget {
6
6
const PreviousGamesView ({
7
7
Key key,
8
+ this .homeTeamGames,
9
+ this .oppTeamGames,
8
10
}) : super (key: key);
9
11
12
+ final List <dynamic > homeTeamGames;
13
+ final List <dynamic > oppTeamGames;
14
+
10
15
@override
11
16
Widget build (BuildContext context) {
12
17
return Container (
@@ -21,24 +26,16 @@ class PreviousGamesView extends StatelessWidget {
21
26
children: [
22
27
Expanded (
23
28
child: Column (
24
- children: [
25
- PreviousGame (),
26
- PreviousGame (),
27
- PreviousGame (),
28
- PreviousGame (),
29
- PreviousGame (),
30
- ],
29
+ children: homeTeamGames
30
+ .map ((game) => PreviousGame (game: game))
31
+ .toList (),
31
32
),
32
33
),
33
34
Expanded (
34
35
child: Column (
35
- children: [
36
- PreviousGame (),
37
- PreviousGame (),
38
- PreviousGame (),
39
- PreviousGame (),
40
- PreviousGame (),
41
- ],
36
+ children: oppTeamGames
37
+ .map ((game) => PreviousGame (game: game))
38
+ .toList (),
42
39
),
43
40
),
44
41
],
Original file line number Diff line number Diff line change @@ -3,12 +3,16 @@ import 'package:flutter/material.dart';
3
3
class Scorers extends StatelessWidget {
4
4
const Scorers ({
5
5
Key key,
6
+ this .homeGoalie,
7
+ this .oppGoalie,
6
8
}) : super (key: key);
7
9
10
+ final homeGoalie;
11
+ final oppGoalie;
12
+
8
13
@override
9
14
Widget build (BuildContext context) {
10
15
return Container (
11
- // height: 150,
12
16
child: Column (
13
17
children: [
14
18
Text (
@@ -18,28 +22,32 @@ class Scorers extends StatelessWidget {
18
22
Row (
19
23
mainAxisAlignment: MainAxisAlignment .spaceBetween,
20
24
children: [
21
- _playerInfo (),
22
- _playerInfo (),
25
+ _playerInfo (true ),
26
+ _playerInfo (false ),
23
27
],
24
28
)
25
29
],
26
30
),
27
31
);
28
32
}
29
33
30
- Widget _playerInfo () {
34
+ Widget _playerInfo (bool isHomeTeam ) {
31
35
return Container (
32
36
child: Column (
33
37
mainAxisAlignment: MainAxisAlignment .spaceAround,
34
38
children: [
35
- Image .asset (
36
- 'assets/images/player_face.jpg' ,
37
- width: 50 ,
39
+ Image .network (
40
+ isHomeTeam
41
+ ? '${homeGoalie ['urlToImage' ]}'
42
+ : '${oppGoalie ['urlToImage' ]}' ,
43
+ width: 100 ,
38
44
),
39
45
SizedBox (height: 8 ),
40
- Text ('Player Name' ),
46
+ Text (isHomeTeam
47
+ ? '${homeGoalie ['player_name' ]}'
48
+ : '${oppGoalie ['player_name' ]}' ),
41
49
SizedBox (height: 8 ),
42
- Text ('11' ),
50
+ // Text('11'),
43
51
SizedBox (height: 16 ),
44
52
],
45
53
),
Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ import 'package:flutter/material.dart';
3
3
class PreviousGame extends StatelessWidget {
4
4
const PreviousGame ({
5
5
Key key,
6
+ this .game,
6
7
}) : super (key: key);
7
8
9
+ final game;
10
+
8
11
Text get _flagText {
9
12
return Text (
10
13
'G' ,
@@ -30,9 +33,13 @@ class PreviousGame extends StatelessWidget {
30
33
}
31
34
32
35
Widget get _label {
33
- return Text (
34
- 'vs Team Name 0:0' ,
35
- style: TextStyle (color: Colors .grey),
36
+ return Expanded (
37
+ child: Text (
38
+ game != null
39
+ ? 'vs ${game ['homeTeam' ]['name' ]} ${game ['score' ]}'
40
+ : ' vs Team Name 0-0' ,
41
+ style: TextStyle (color: Colors .grey),
42
+ ),
36
43
);
37
44
}
38
45
Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ const resolvers = {
117
117
const parsed = await response . json ( ) ;
118
118
119
119
// Filter to just the 2 teams requested
120
+ if ( parsed . api . standings == null ) return null ;
120
121
const teamsToCompare = parsed . api . standings [ 0 ] . filter ( ( element , index , array ) => {
121
122
return teamNames . includes ( element . teamName ) ;
122
123
} ) ;
You can’t perform that action at this time.
0 commit comments