Fixed state problem with games list
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m6s
Pull Request Pipeline / lint (pull_request) Successful in 2m6s

This commit is contained in:
2025-12-09 18:26:05 +01:00
parent 062c2681bf
commit 701500c7e2
3 changed files with 23 additions and 16 deletions

View File

@@ -98,17 +98,16 @@ class _GameHistoryViewState extends State<GameHistoryView> {
}
return GameHistoryTile(
onTap: () async {
await Navigator.push(
Navigator.push(
context,
CupertinoPageRoute(
fullscreenDialog: true,
builder: (context) =>
GameResultView(game: games[index]),
builder: (context) => GameResultView(
game: games[index],
onWinnerChanged: refreshGameList,
),
),
);
setState(() {
_gameListFuture = db.gameDao.getAllGames();
});
},
game: games[index],
);
@@ -123,17 +122,13 @@ class _GameHistoryViewState extends State<GameHistoryView> {
text: 'Create Game',
sizeRelativeToWidth: 0.90,
onPressed: () async {
await Navigator.push(
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return const CreateGameView();
},
builder: (context) =>
CreateGameView(onWinnerChanged: refreshGameList),
),
);
setState(() {
_gameListFuture = db.gameDao.getAllGames();
});
},
),
),
@@ -141,4 +136,10 @@ class _GameHistoryViewState extends State<GameHistoryView> {
),
);
}
void refreshGameList() {
setState(() {
_gameListFuture = db.gameDao.getAllGames();
});
}
}