yagizdo/tictactoe-multiplayer-game

Draw and win time - timer bug

Opened this issue · 2 comments

If someone wins or draws, the game stops, but the timer works again. But the timer should not work either.

Got the solution, Do some changes as below

add/update in below files

1) navigation_service

void navigateToFirst() {
return Navigator.of(navigatorKey.currentContext!).popUntil((route) => route.isFirst);
}

2)game_view_model

@action
void quitGame(bool isDialog) {
resetGame();
if(isDialog){
_navigationService.navigateToFirst();
}
_navigationService.navigateTo(Routes.homeViewRoute);
}

3) game_dialog_quit_button

@OverRide
Widget build(BuildContext context) {
return SizedBox(
width: 126.w,
height: 40.h,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
red,
),
elevation: MaterialStateProperty.all(0),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
onPressed: () {
_gameViewModel.quitGame(true);

    },
    child: Row(
      children: [
        const Icon(Icons.close),
        width5,
        Text(
          'Quit',
          style: Theme.of(context).textTheme.labelSmall,
        ),
      ],
    ),
  ),
);

}

4) quit_button

@OverRide
Widget build(BuildContext context) {
return SizedBox(
width: 100.w,
height: 40.h,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
purple.withOpacity(0.5),
),
elevation: MaterialStateProperty.all(0),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
onPressed: () {
_gameViewModel.quitGame(false);
},
child: Row(
children: [
const Icon(Icons.close),
width9,
const Text('Quit'),
],
),
),
);
}

Thank you for your answer.

I tried the answer you said but it is not fixed. In case I missed something,I created a new branch and pushed the added version of the code you said.

Commit: 4b4e5cd