diff --git a/game_template/lib/main.dart b/game_template/lib/main.dart index 57f3cfbe3..90c1f02b0 100644 --- a/game_template/lib/main.dart +++ b/game_template/lib/main.dart @@ -157,6 +157,16 @@ class MyApp extends StatelessWidget { ), GoRoute( path: 'won', + redirect: (context, state) { + if (state.extra == null) { + // Trying to navigate to a win screen without any data. + // Possibly by using the browser's back button. + return '/'; + } + + // Otherwise, do not redirect. + return null; + }, pageBuilder: (context, state) { final map = state.extra! as Map; final score = map['score'] as Score;