@@ -26,24 +26,19 @@ class GamePage extends StatelessWidget {
2626 return const Center (child: CircularProgressIndicator ());
2727 }
2828
29- return BlocProvider (
30- create: (context) => TimerBloc ()..add (const TimerStartEvent ()),
31- child: BlocListener <GameBloc , GameState >(
32- listener: (context, state) {
33- if (state.status == GameStatus .finished) {
34- context.read <TimerBloc >().add (const TimerPauseEvent ());
35- final gameLength = context.read <TimerBloc >().state.elapsedSeconds;
36- context
37- .read <GameBloc >()
38- .add (GameUpdateTimerEvent (gameLength: gameLength));
39- context.read <TimerBloc >().add (const TimerResetEvent ());
40- context.read <TimerBloc >().add (const TimerPauseEvent ());
41- context.go (GameOverPage .routePath);
42- }
43- },
44- child:
45- playerCount == 2 ? const TwoPlayerGame () : const FourPlayerGame (),
46- ),
29+ return BlocListener <GameBloc , GameState >(
30+ listener: (context, state) {
31+ if (state.status == GameStatus .finished) {
32+ context.read <TimerBloc >().add (const TimerPauseEvent ());
33+ final gameLength = context.read <TimerBloc >().state.elapsedSeconds;
34+ context
35+ .read <GameBloc >()
36+ .add (GameUpdateTimerEvent (gameLength: gameLength));
37+
38+ context.go (GameOverPage .routePath);
39+ }
40+ },
41+ child: playerCount == 2 ? const TwoPlayerGame () : const FourPlayerGame (),
4742 );
4843 }
4944}
0 commit comments