Skip to content

Commit f2759c9

Browse files
committed
refactor(navigation): Use go_router for settings navigation
Replaced the `MaterialPageRoute` for navigating to the `SettingsPage` with `context.push("/settings")` to utilize `go_router`. - Added a new `/settings` route in `lib/route.dart`. - Removed a redundant `/main` route redirect.
1 parent dff087e commit f2759c9

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

lib/route.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:escape_wild/ui/game/backpack/backpack.dart';
33
import 'package:escape_wild/ui/game/craft/craft.dart';
44
import 'package:escape_wild/ui/game/index.dart';
55
import 'package:escape_wild/ui/main/game.dart';
6+
import 'package:escape_wild/ui/main/settings.dart';
67
import 'package:flutter/widgets.dart';
78
import 'package:go_router/go_router.dart';
89

@@ -14,13 +15,7 @@ RoutingConfig buildRoutingConfig() {
1415
return RoutingConfig(
1516
routes: [
1617
GoRoute(path: "/", builder: (ctx, state) => GamePage()),
17-
GoRoute(
18-
path: "/main",
19-
redirect: (ctx, state) {
20-
if (state.fullPath == "/main") return "/main/game";
21-
return null;
22-
},
23-
),
18+
GoRoute(path: "/settings", builder: (ctx, state) => SettingsPage()),
2419
GoRoute(
2520
path: "/game",
2621
redirect: (ctx, state) {

lib/ui/main/game.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import 'package:rettulf/rettulf.dart';
66
import 'package:easy_localization/easy_localization.dart';
77
import 'package:tabler_icons/tabler_icons.dart';
88

9-
import 'settings.dart';
10-
119
part 'game.i18n.dart';
1210

1311
class GamePage extends StatefulWidget {
@@ -28,7 +26,7 @@ class _GamePageState extends State<GamePage> {
2826
actions: [
2927
IconButton(
3028
onPressed: () {
31-
context.navigator.push(MaterialPageRoute(builder: (_) => const SettingsPage()));
29+
context.push("/settings");
3230
},
3331
icon: const Icon(TablerIcons.settings),
3432
),

0 commit comments

Comments
 (0)