From dd4fc132a1371e8caef2d29c47c05e3af9f61ad4 Mon Sep 17 00:00:00 2001 From: Filip Hracek Date: Sun, 4 Jun 2023 23:52:31 +0200 Subject: [PATCH] Provide LocalKey to every custom transition (#1869) Fixes #1551. Also, remove superfluous `debugPrint` calls and other `Logger` setup since the latest `pkg:logging` does this stuff automatically and so the setup lead to duplicate messages in console. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/wiki/Chat [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md --- game_template/lib/main.dart | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/game_template/lib/main.dart b/game_template/lib/main.dart index 90c1f02b0..bb548fbaf 100644 --- a/game_template/lib/main.dart +++ b/game_template/lib/main.dart @@ -8,7 +8,6 @@ // import 'firebase_options.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; @@ -64,16 +63,6 @@ Future main() async { /// Without logging and crash reporting, this would be `void main()`. void guardedMain() { - if (kReleaseMode) { - // Don't log anything below warnings in production. - Logger.root.level = Level.WARNING; - } - Logger.root.onRecord.listen((record) { - debugPrint('${record.level.name}: ${record.time}: ' - '${record.loggerName}: ' - '${record.message}'); - }); - WidgetsFlutterBinding.ensureInitialized(); _log.info('Going full screen'); @@ -134,8 +123,10 @@ class MyApp extends StatelessWidget { GoRoute( path: 'play', pageBuilder: (context, state) => buildMyTransition( + key: ValueKey('play'), child: const LevelSelectionScreen( - key: Key('level selection')), + key: Key('level selection'), + ), color: context.watch().backgroundLevelSelection, ), routes: [ @@ -147,6 +138,7 @@ class MyApp extends StatelessWidget { final level = gameLevels .singleWhere((e) => e.number == levelNumber); return buildMyTransition( + key: ValueKey('level'), child: PlaySessionScreen( level, key: const Key('play session'), @@ -172,6 +164,7 @@ class MyApp extends StatelessWidget { final score = map['score'] as Score; return buildMyTransition( + key: ValueKey('won'), child: WinGameScreen( score: score, key: const Key('win game'),