fix: callbacks when game deletes matches
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 44s
Pull Request Pipeline / lint (pull_request) Successful in 47s

This commit is contained in:
2026-05-03 10:45:18 +02:00
parent e3aef81ab6
commit 5d832c98a7
3 changed files with 9 additions and 2 deletions

View File

@@ -177,6 +177,7 @@ class _ChooseGameViewState extends State<ChooseGameView> {
if (result.delete) {
setState(() {
widget.games.removeAt(originalIndex);
widget.onGamesUpdated?.call();
});
} else {
setState(() {

View File

@@ -28,10 +28,13 @@ class CreateMatchView extends StatefulWidget {
this.onWinnerChanged,
this.matchToEdit,
this.onMatchUpdated,
this.onMatchesUpdated,
});
final VoidCallback? onWinnerChanged;
final VoidCallback? onMatchesUpdated;
final void Function(Match)? onMatchUpdated;
/// An optional match to prefill the fields for editing.
@@ -138,6 +141,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
builder: (context) => ChooseGameView(
games: gamesList,
initialGameId: selectedGame?.id ?? '',
onGamesUpdated: widget.onMatchesUpdated,
),
),
);

View File

@@ -118,8 +118,10 @@ class _MatchViewState extends State<MatchView> {
Navigator.push(
context,
adaptivePageRoute(
builder: (context) =>
CreateMatchView(onWinnerChanged: loadMatches),
builder: (context) => CreateMatchView(
onWinnerChanged: loadMatches,
onMatchesUpdated: loadMatches,
),
),
);
},