@@ -40,8 +40,8 @@ class FlutterFlipApp extends StatelessWidget {
40
40
onGenerateRoute: (settings) {
41
41
return PageRouteBuilder <dynamic >(
42
42
settings: settings,
43
- pageBuilder:
44
- (context, animation, secondaryAnimation) => const GameScreen (),
43
+ pageBuilder: (context, animation, secondaryAnimation) =>
44
+ const GameScreen (),
45
45
);
46
46
},
47
47
);
@@ -91,33 +91,34 @@ class GameScreenState extends State<GameScreen> {
91
91
// moves, and models with the results of CPU moves. These are fed into the
92
92
// StreamBuilder in [build], and used to create the widgets that comprise
93
93
// the game's display.
94
- _modelStream = StreamGroup .merge ([
95
- _userMovesController.stream,
96
- _restartController.stream,
97
- ]).asyncExpand ((model) async * {
98
- yield model;
94
+ _modelStream =
95
+ StreamGroup .merge ([
96
+ _userMovesController.stream,
97
+ _restartController.stream,
98
+ ]).asyncExpand ((model) async * {
99
+ yield model;
99
100
100
- var newModel = model;
101
+ var newModel = model;
101
102
102
- while (newModel.player == PieceType .white) {
103
- final finder = MoveFinder (newModel.board);
104
- final moveFuture = finder.findNextMove (newModel.player, 5 );
103
+ while (newModel.player == PieceType .white) {
104
+ final finder = MoveFinder (newModel.board);
105
+ final moveFuture = finder.findNextMove (newModel.player, 5 );
105
106
106
- // Guarantee the move takes at least a second to arrive, giving the UI
107
- // a chance to animate for each move.
108
- final result = await Future .wait ([
109
- moveFuture,
110
- Future .delayed (Duration (seconds: 1 )),
111
- ]);
107
+ // Guarantee the move takes at least a second to arrive, giving the UI
108
+ // a chance to animate for each move.
109
+ final result = await Future .wait ([
110
+ moveFuture,
111
+ Future .delayed (Duration (seconds: 1 )),
112
+ ]);
112
113
113
- final move = result[0 ] as Position ? ;
114
+ final move = result[0 ] as Position ? ;
114
115
115
- if (move != null ) {
116
- newModel = newModel.updateForMove (move.x, move.y);
117
- yield newModel;
118
- }
119
- }
120
- });
116
+ if (move != null ) {
117
+ newModel = newModel.updateForMove (move.x, move.y);
118
+ yield newModel;
119
+ }
120
+ }
121
+ });
121
122
}
122
123
123
124
// Thou shalt tidy up thy stream controllers.
@@ -155,16 +156,14 @@ class GameScreenState extends State<GameScreen> {
155
156
156
157
Widget _buildScoreBox (PieceType player, GameModel model) {
157
158
var label = player == PieceType .black ? 'black' : 'white' ;
158
- var scoreText =
159
- player == PieceType .black
160
- ? '${model .blackScore }'
161
- : '${model .whiteScore }' ;
159
+ var scoreText = player == PieceType .black
160
+ ? '${model .blackScore }'
161
+ : '${model .whiteScore }' ;
162
162
163
163
return DecoratedBox (
164
- decoration:
165
- (model.player == player)
166
- ? Styling .activePlayerIndicator
167
- : Styling .inactivePlayerIndicator,
164
+ decoration: (model.player == player)
165
+ ? Styling .activePlayerIndicator
166
+ : Styling .inactivePlayerIndicator,
168
167
child: Column (
169
168
children: < Widget > [
170
169
Text (
0 commit comments