Skip to content

Commit 037ef7f

Browse files
committed
feat: web navigation
1 parent 2ef44a9 commit 037ef7f

File tree

4 files changed

+60
-19
lines changed

4 files changed

+60
-19
lines changed

lib/main.dart

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
3+
import 'package:go_router/go_router.dart';
24
import 'package:portfolio/pages/home_page.dart';
5+
import 'package:portfolio/pages/projects/cofence_page.dart';
6+
import 'package:portfolio/pages/projects/fencing_tableau_page.dart';
7+
import 'package:portfolio/pages/projects/funcially_page.dart';
38

49
void main() {
5-
runApp(MaterialApp(
6-
debugShowCheckedModeBanner: false,
7-
themeMode: ThemeMode.dark,
8-
theme: ThemeData.dark(useMaterial3: true),
9-
home: const HomePage(),
10-
));
10+
usePathUrlStrategy();
11+
runApp(
12+
MaterialApp.router(
13+
debugShowCheckedModeBanner: false,
14+
themeMode: ThemeMode.dark,
15+
theme: ThemeData.dark(useMaterial3: true),
16+
routerConfig: GoRouter(
17+
initialLocation: "/",
18+
routes: [
19+
GoRoute(
20+
path: "/",
21+
builder: (context, state) => const HomePage(),
22+
routes: [
23+
GoRoute(
24+
path: "fencing-tableau",
25+
builder: (context, state) => const FencingTableauPage(),
26+
),
27+
GoRoute(
28+
path: "funcially",
29+
builder: (context, state) => const FunciallyPage(),
30+
),
31+
GoRoute(
32+
path: "cofence",
33+
builder: (context, state) => const CofencePage(),
34+
),
35+
],
36+
),
37+
],
38+
),
39+
),
40+
);
1141
}

lib/pages/home_page.dart

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:ui';
22

33
import 'package:flutter/foundation.dart';
44
import 'package:flutter/material.dart';
5+
import 'package:go_router/go_router.dart';
56
import 'package:portfolio/pages/project_page.dart';
67
import 'package:portfolio/pages/projects/cofence_page.dart';
78
import 'package:portfolio/pages/projects/fencing_tableau_page.dart';
@@ -150,26 +151,17 @@ class _ProjectsList extends StatelessWidget {
150151
_ProjectCard(
151152
backgroundImage: "assets/fencing_tableau_thumbnail.png",
152153
name: "Fencing Tableau",
153-
onTap: () => Navigator.push(
154-
context,
155-
MaterialPageRoute(builder: (_) => const FencingTableauPage()),
156-
),
154+
onTap: () => context.go("/fencing-tableau"),
157155
),
158156
_ProjectCard(
159157
backgroundImage: "assets/funcially_thumbnail.png",
160158
name: "Funcially",
161-
onTap: () => Navigator.push(
162-
context,
163-
MaterialPageRoute(builder: (_) => const FunciallyPage()),
164-
),
159+
onTap: () => context.go("/funcially"),
165160
),
166161
_ProjectCard(
167162
backgroundImage: "assets/cofence_thumbnail.png",
168163
name: "Cofence",
169-
onTap: () => Navigator.push(
170-
context,
171-
MaterialPageRoute(builder: (_) => const CofencePage()),
172-
),
164+
onTap: () => context.go("/cofence"),
173165
),
174166
],
175167
),

pubspec.lock

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,18 @@ packages:
7676
source: sdk
7777
version: "0.0.0"
7878
flutter_web_plugins:
79-
dependency: transitive
79+
dependency: "direct main"
8080
description: flutter
8181
source: sdk
8282
version: "0.0.0"
83+
go_router:
84+
dependency: "direct main"
85+
description:
86+
name: go_router
87+
sha256: "8ae664a70174163b9f65ea68dd8673e29db8f9095de7b5cd00e167c621f4fef5"
88+
url: "https://pub.dev"
89+
source: hosted
90+
version: "14.6.0"
8391
leak_tracker:
8492
dependency: transitive
8593
description:
@@ -112,6 +120,14 @@ packages:
112120
url: "https://pub.dev"
113121
source: hosted
114122
version: "4.0.0"
123+
logging:
124+
dependency: transitive
125+
description:
126+
name: logging
127+
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
128+
url: "https://pub.dev"
129+
source: hosted
130+
version: "1.3.0"
115131
matcher:
116132
dependency: transitive
117133
description:

pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ environment:
99
dependencies:
1010
flutter:
1111
sdk: flutter
12+
flutter_web_plugins:
13+
sdk: flutter
1214
cupertino_icons: ^1.0.8
1315
url_launcher: ^6.3.1
16+
go_router: ^14.6.0
1417

1518
dev_dependencies:
1619
flutter_test:

0 commit comments

Comments
 (0)