mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
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. <!-- Links --> [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
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
// import 'firebase_options.dart';
|
// import 'firebase_options.dart';
|
||||||
|
|
||||||
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
@@ -64,16 +63,6 @@ Future<void> main() async {
|
|||||||
|
|
||||||
/// Without logging and crash reporting, this would be `void main()`.
|
/// Without logging and crash reporting, this would be `void main()`.
|
||||||
void guardedMain() {
|
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();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
_log.info('Going full screen');
|
_log.info('Going full screen');
|
||||||
@@ -134,8 +123,10 @@ class MyApp extends StatelessWidget {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'play',
|
path: 'play',
|
||||||
pageBuilder: (context, state) => buildMyTransition<void>(
|
pageBuilder: (context, state) => buildMyTransition<void>(
|
||||||
|
key: ValueKey('play'),
|
||||||
child: const LevelSelectionScreen(
|
child: const LevelSelectionScreen(
|
||||||
key: Key('level selection')),
|
key: Key('level selection'),
|
||||||
|
),
|
||||||
color: context.watch<Palette>().backgroundLevelSelection,
|
color: context.watch<Palette>().backgroundLevelSelection,
|
||||||
),
|
),
|
||||||
routes: [
|
routes: [
|
||||||
@@ -147,6 +138,7 @@ class MyApp extends StatelessWidget {
|
|||||||
final level = gameLevels
|
final level = gameLevels
|
||||||
.singleWhere((e) => e.number == levelNumber);
|
.singleWhere((e) => e.number == levelNumber);
|
||||||
return buildMyTransition<void>(
|
return buildMyTransition<void>(
|
||||||
|
key: ValueKey('level'),
|
||||||
child: PlaySessionScreen(
|
child: PlaySessionScreen(
|
||||||
level,
|
level,
|
||||||
key: const Key('play session'),
|
key: const Key('play session'),
|
||||||
@@ -172,6 +164,7 @@ class MyApp extends StatelessWidget {
|
|||||||
final score = map['score'] as Score;
|
final score = map['score'] as Score;
|
||||||
|
|
||||||
return buildMyTransition<void>(
|
return buildMyTransition<void>(
|
||||||
|
key: ValueKey('won'),
|
||||||
child: WinGameScreen(
|
child: WinGameScreen(
|
||||||
score: score,
|
score: score,
|
||||||
key: const Key('win game'),
|
key: const Key('win game'),
|
||||||
|
|||||||
Reference in New Issue
Block a user