Skip to content

Commit

Permalink
Fix game starts even when cancelling "show roles" dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
evgfilim1 committed Apr 12, 2024
1 parent faa27f6 commit cf22338
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/screens/choose_roles_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ class _ChooseRolesScreenState extends State<ChooseRolesScreen> {
showSnackBar(context, const SnackBar(content: Text("Для продолжения исправьте ошибки")));
return;
}
final controller = context.read<GameController>();
final newRoles = _randomizeRoles();
if (newRoles == null) {
showSnackBar(
Expand All @@ -202,10 +201,6 @@ class _ChooseRolesScreenState extends State<ChooseRolesScreen> {
);
return;
}
controller
..roles = newRoles
..nicknames = _chosenNicknames
..startNewGame();
final showRoles = await showDialog<bool>(
context: context,
builder: (context) => const ConfirmationDialog(
Expand All @@ -220,6 +215,10 @@ class _ChooseRolesScreenState extends State<ChooseRolesScreen> {
if (showRoles == null) {
return;
}
context.read<GameController>()
..roles = newRoles
..nicknames = _chosenNicknames
..startNewGame();
if (showRoles) {
await Navigator.pushNamed(context, "/roles");
if (!context.mounted) {
Expand Down

0 comments on commit cf22338

Please sign in to comment.