Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
37be48c
- Adds `GoRouter.goRelative`
ThangVuNguyenViet May 29, 2024
f8061ce
add go_relative example for go_router
ThangVuNguyenViet May 29, 2024
8a77147
add go_relative_test for the example
ThangVuNguyenViet May 29, 2024
61127f3
fix failed test
ThangVuNguyenViet May 29, 2024
687b332
replace goRelative with go('./$path')
ThangVuNguyenViet Jun 19, 2024
cca1454
Commit missing files during merge
ThangVuNguyenViet Jun 19, 2024
975128b
update changelog & version
ThangVuNguyenViet Jun 19, 2024
6d90488
Prevent concatenateUris from adding trailing redundant '?'. Add test …
ThangVuNguyenViet Jun 19, 2024
ccb38f9
Add more `concatenateUris` test. Fix joining params
ThangVuNguyenViet Jun 19, 2024
80d85d6
update example description
ThangVuNguyenViet Jul 10, 2024
a09aa94
Make concatenateUris not merging parameters, only take them from chil…
ThangVuNguyenViet Jul 19, 2024
a174cbe
Add GoRelativeRouteConfig
ThangVuNguyenViet Jul 10, 2024
4cb0334
Add test, examples and example tests for go_router_builder. Temporari…
ThangVuNguyenViet Jul 19, 2024
ceaa318
Add relativeLocation, push, pushReplacement & replace to the Relative…
ThangVuNguyenViet Jul 19, 2024
d3b5355
Merge branch 'flutter-main'
ThangVuNguyenViet Jan 22, 2025
07b4a23
update go_router package dependency
ThangVuNguyenViet Jan 22, 2025
6008b8b
Fix merge issues
ThangVuNguyenViet Jan 22, 2025
d2fbc0e
temporarily add dependency_override
ThangVuNguyenViet Jan 22, 2025
8b5fb4d
change relative route actions to have suffix `Relative`
ThangVuNguyenViet Feb 3, 2025
02c3d7b
Fix example
ThangVuNguyenViet Feb 4, 2025
72c06de
Update go_relative test
ThangVuNguyenViet Feb 6, 2025
edef7a5
Merge branch 'main' of github.com:flutter/packages
ThangVuNguyenViet May 17, 2025
5474303
fix generated file
ThangVuNguyenViet May 17, 2025
dbf7f9d
Fix failed test due to generated files
ThangVuNguyenViet May 17, 2025
37c5490
Merge branch 'main' of github.com:flutter/packages
ThangVuNguyenViet Jun 2, 2025
868a2d5
Merge branch 'main' of github.com:flutter/packages
ThangVuNguyenViet Jun 12, 2025
232dc7d
Merge branch 'main' of github.com:flutter/packages
ThangVuNguyenViet Jul 1, 2025
1d5ad11
Merge branch 'main' of github.com:flutter/packages
ThangVuNguyenViet Jul 9, 2025
f899939
Remove GoRouteData routing methods. Update TypedRelativeGoRoute gener…
ThangVuNguyenViet Jul 9, 2025
92f6cac
remove overrides on other tests
ThangVuNguyenViet Jul 9, 2025
f98505e
make sure relative go route generated code resembles typed go route a…
ThangVuNguyenViet Jul 9, 2025
20fd5d6
update changelog
ThangVuNguyenViet Jul 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update go_relative test
  • Loading branch information
ThangVuNguyenViet committed Feb 6, 2025
commit 72c06de008c84b1a371e2fa44cd1c88ce2a5ec67
74 changes: 58 additions & 16 deletions packages/go_router_builder/example/lib/go_relative.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ const TypedRelativeGoRoute<DetailsRoute> detailRoute =

@TypedGoRoute<HomeRoute>(
path: '/',
routes: <TypedRoute<RouteData>>[detailRoute],
routes: <TypedRoute<RouteData>>[
TypedGoRoute<DashboardRoute>(
path: '/dashboard',
routes: <TypedRoute<RouteData>>[detailRoute],
),
detailRoute,
],
)
class HomeRoute extends GoRouteData {
@override
Expand All @@ -47,6 +53,13 @@ class HomeRoute extends GoRouteData {
}
}

class DashboardRoute extends GoRouteData {
@override
Widget build(BuildContext context, GoRouterState state) {
return const DashboardScreen();
}
}

class DetailsRoute extends GoRouteData {
const DetailsRoute({required this.detailId});
final String detailId;
Expand All @@ -70,26 +83,57 @@ class SettingsRoute extends GoRouteData {
}

/// The home screen
class HomeScreen extends StatefulWidget {
class HomeScreen extends StatelessWidget {
/// Constructs a [HomeScreen]
const HomeScreen({super.key});

@override
State<HomeScreen> createState() => _HomeScreenState();
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home Screen')),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
const DetailsRoute(detailId: 'DetailsId').goRelative(context);
},
child: const Text('Go to the Details screen'),
),
ElevatedButton(
onPressed: () {
DashboardRoute().go(context);
},
child: const Text('Go to the Dashboard screen'),
),
],
),
);
}
}

class _HomeScreenState extends State<HomeScreen> {
/// The home screen
class DashboardScreen extends StatelessWidget {
/// Constructs a [DashboardScreen]
const DashboardScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home Screen')),
body: Center(
child: ElevatedButton(
onPressed: () {
const DetailsRoute(detailId: 'DetailsId').goRelative(context);
},
child: const Text('Go to the Details screen'),
),
appBar: AppBar(title: const Text('Dashboard Screen')),
body: Column(
children: <Widget>[
ElevatedButton(
onPressed: () {
const DetailsRoute(detailId: 'DetailsId').goRelative(context);
},
child: const Text('Go to the Details screen'),
),
ElevatedButton(
onPressed: () => context.pop(),
child: const Text('Go back'),
),
],
),
);
}
Expand All @@ -113,7 +157,7 @@ class DetailsScreen extends StatelessWidget {
child: Column(
children: <Widget>[
ElevatedButton(
onPressed: () => HomeRoute().go(context),
onPressed: () => context.pop(),
child: const Text('Go back'),
),
ElevatedButton(
Expand Down Expand Up @@ -145,9 +189,7 @@ class SettingsScreen extends StatelessWidget {
appBar: AppBar(title: Text('Settings Screen $id')),
body: Center(
child: TextButton(
onPressed: () {
context.pop();
},
onPressed: () => context.pop(),
child: const Text('Go back'),
),
),
Expand Down
33 changes: 33 additions & 0 deletions packages/go_router_builder/example/lib/go_relative.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions packages/go_router_builder/example/test/go_relative_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void main() {
await tester.pumpWidget(const example.MyApp());
expect(find.byType(example.HomeScreen), findsOneWidget);

// From Home screen, go to Details screen
await tester.tap(find.text('Go to the Details screen'));
await tester.pumpAndSettle();
expect(find.byType(example.DetailsScreen), findsOneWidget);
Expand All @@ -25,5 +26,30 @@ void main() {
await tester.tap(find.text('Go back'));
await tester.pumpAndSettle();
expect(find.byType(example.HomeScreen), findsOneWidget);

await tester.tap(find.text('Go to the Dashboard screen'));
await tester.pumpAndSettle();
expect(find.byType(example.DashboardScreen), findsOneWidget);

// From Dashboard screen, go to Details screen
await tester.tap(find.text('Go to the Details screen'));
await tester.pumpAndSettle();
expect(find.byType(example.DetailsScreen), findsOneWidget);

await tester.tap(find.text('Go to the Settings screen'));
await tester.pumpAndSettle();
expect(find.byType(example.SettingsScreen), findsOneWidget);

await tester.tap(find.text('Go back'));
await tester.pumpAndSettle();
expect(find.byType(example.DetailsScreen), findsOneWidget);

await tester.tap(find.text('Go back'));
await tester.pumpAndSettle();
expect(find.byType(example.DashboardScreen), findsOneWidget);

await tester.tap(find.text('Go back'));
await tester.pumpAndSettle();
expect(find.byType(example.HomeScreen), findsOneWidget);
});
}