Skip to content

Commit aa757d1

Browse files
masreplayclaude
andcommitted
Merge branch 'claude/flutter-navigation-devtools' into feat/initial-implementation
Adopt the generic navigation_devtools architecture (multi-router core with auto_route/go_router/Navigator1/RouterDelegate adapters) as canonical. Structural rename conflicts resolved in favour of the generic packages; old auto_route_devtools_{shared,extension} packages removed. The route-graph, param-entry and nested-nav feature sources from feat/initial-implementation are retained under packages/auto_route_devtools_extension/ pending port into navigation_devtools_extension. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 parents dc3c209 + 6c8bb18 commit aa757d1

174 files changed

Lines changed: 70156 additions & 66622 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yaml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
analyze-and-test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: subosito/flutter-action@v2
14+
with:
15+
channel: stable
16+
cache: true
17+
- name: Bootstrap workspace
18+
run: flutter pub get
19+
- name: Analyze
20+
run: flutter analyze packages examples
21+
- name: Test
22+
run: >
23+
flutter test
24+
packages/navigation_devtools_shared
25+
packages/navigation_devtools
26+
packages/go_router_devtools
27+
packages/auto_route_devtools
28+
packages/navigation_devtools_extension
29+
- name: Publish dry-runs
30+
run: |
31+
for p in navigation_devtools navigation_devtools_shared navigation_devtools_test go_router_devtools auto_route_devtools; do
32+
(cd packages/$p && flutter pub publish --dry-run)
33+
done
34+
35+
bundle-drift:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: subosito/flutter-action@v2
40+
with:
41+
channel: stable
42+
cache: true
43+
- name: Bootstrap workspace
44+
run: flutter pub get
45+
- name: Rebuild extension bundle
46+
working-directory: packages/navigation_devtools_extension
47+
run: dart run devtools_extensions build_and_copy --source=. --dest=../navigation_devtools/extension/devtools
48+
- name: Fail if the committed bundle drifted
49+
# Compiled JS differs run-to-run; assert the asset *file set* matches
50+
# so a UI change without a bundle rebuild fails CI.
51+
run: |
52+
git status --porcelain packages/navigation_devtools/extension/devtools \
53+
| grep -E '^\?\?|^ D' && {
54+
echo 'Extension bundle file set drifted — run build_and_copy and commit.';
55+
exit 1;
56+
} || echo 'Bundle file set is consistent.'

‎.gitignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.dart_tool/
22
build/
33
# DevTools extension bundle must ship in the published package
4-
!packages/auto_route_devtools/extension/devtools/build/
5-
!packages/auto_route_devtools/extension/devtools/build/**
4+
!packages/navigation_devtools/extension/devtools/build/
5+
!packages/navigation_devtools/extension/devtools/build/**
66
.packages
77
pubspec.lock
88
*.iml

‎README.md‎

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,104 @@
1-
# auto_route_devtools (monorepo)
1+
# navigation_devtools (monorepo)
22

3-
A Flutter DevTools panel extension for [auto_route](https://pub.dev/packages/auto_route) that surfaces the live backstack, the full router tree, route args/params, and confirm-gated interactive navigation directly inside Flutter DevTools. Unlike auto_route (which ships no DevTools extension) and `developer_tools_auto_route` (an in-app overlay), this is a proper DevTools panel.
3+
One Flutter DevTools panel for **every** kind of Flutter navigation. Inspect the live backstack, browse the declared route tree, view per-route args/params, and drive confirm-gated navigation from the panel — whether your app uses Navigator 1.0, a hand-written Navigator 2.0 `RouterDelegate`, go_router, or auto_route.
44

5-
- Package: [`packages/auto_route_devtools/`](packages/auto_route_devtools/) — the publishable package and its README/setup guide.
6-
- Design docs: [`docs/superpowers/`](docs/superpowers/) — specs and implementation plans.
5+
![The panel inspecting a go_router app](docs/images/panel_go_router.png)
6+
7+
## Packages
8+
9+
| Package | What it is | Use it when |
10+
|---|---|---|
11+
| [`navigation_devtools`](packages/navigation_devtools/) | Core: adapter API, DevTools panel bundle, Navigator 1.0 + generic RouterDelegate adapters, adapter conformance test kit | `MaterialApp(routes:)`, imperative push/pop, or a custom `RouterDelegate` |
12+
| [`go_router_devtools`](packages/go_router_devtools/) | go_router adapter | `MaterialApp.router(routerConfig: GoRouter(...))` |
13+
| [`auto_route_devtools`](packages/auto_route_devtools/) | auto_route v11 adapter | `MaterialApp.router(routerConfig: appRouter.config())` |
14+
15+
The DevTools panel ships once, inside `navigation_devtools`; the adapter packages depend on it, so depending on any one of them gets you the panel. Every affordance in the panel is **capability-aware** — a router that can't enumerate its routes simply shows no tree pane; one that can't deep-link shows no path field.
16+
17+
## Quick start
18+
19+
Pick the adapter matching your navigation setup (each snippet is mirrored by a runnable app under [`examples/`](examples/)):
20+
21+
**Navigator 1.0** ([example](examples/navigator1_example/)):
22+
23+
```dart
24+
final adapter = Navigator1Adapter(routes: appRoutes);
25+
NavigationDevTools.register(adapter);
26+
runApp(MaterialApp(routes: appRoutes, navigatorObservers: [adapter.observer]));
27+
```
28+
29+
**Custom RouterDelegate** ([example](examples/router_delegate_example/)):
30+
31+
```dart
32+
NavigationDevTools.register(RouterDelegateAdapter(delegate, parser: parser));
33+
runApp(MaterialApp.router(routerDelegate: delegate, routeInformationParser: parser));
34+
```
35+
36+
**go_router** ([example](examples/go_router_example/)):
37+
38+
```dart
39+
NavigationDevTools.register(GoRouterAdapter(router));
40+
runApp(MaterialApp.router(routerConfig: router));
41+
```
42+
43+
**auto_route** ([example](examples/auto_route_example/)):
44+
45+
```dart
46+
AutoRouteDevTools.init(router);
47+
runApp(MaterialApp.router(
48+
routerConfig: router.config(
49+
navigatorObservers: () => [AutoRouteDevTools.navigationObserver()],
50+
),
51+
));
52+
```
53+
54+
Then run your app and open the **navigation_devtools** tab in Flutter DevTools.
55+
56+
## Capability matrix
57+
58+
| Capability | Navigator 1.0 | RouterDelegate | go_router | auto_route |
59+
|---|---|---|---|---|
60+
| Static route tree | ✅ with `routes:` map | ❌ | ✅ incl. shells | ✅ |
61+
| Guard / redirect badges | ❌ | ❌ | ✅ redirect flag | ✅ guard names |
62+
| Navigate by path | ✅ | ✅ with parser | ✅ `go()` | ✅ |
63+
| Push by name | ✅ | ❌ | ✅ | ❌ |
64+
| Pop | ✅ | ✅ | ✅ | ✅ |
65+
| Nested routers | one adapter per `Navigator` | ❌ | ✅ shells | ✅ |
66+
67+
## Writing your own adapter
68+
69+
Implement `NavigationAdapter` (see [`packages/navigation_devtools`](packages/navigation_devtools/)) and validate it with the bundled conformance kit:
70+
71+
```dart
72+
import 'package:navigation_devtools_test/navigation_devtools_test.dart';
73+
74+
runAdapterConformanceTests('MyAdapter', AdapterHarness(...));
75+
```
76+
77+
## Dialogs & bottom sheets
78+
79+
`showDialog`, `showModalBottomSheet`, and friends push **pageless routes** on the raw `Navigator` — router packages (go_router, auto_route) never see them in their own state.
80+
81+
- **Navigator 1.0 apps:** nothing to do — dialogs and sheets appear on the backstack automatically, badged `pageless` (e.g. `DialogRoute<void>`), and can be popped from the panel.
82+
- **go_router / auto_route / custom delegates:** pair your adapter with a `Navigator1Adapter` observer on the same navigator; it shows up as a second router in the panel's selector, carrying the raw stack including dialogs:
83+
84+
```dart
85+
// go_router
86+
final pageless = Navigator1Adapter(label: 'Pageless routes');
87+
final router = GoRouter(observers: [pageless.observer], routes: [...]);
88+
NavigationDevTools.register(GoRouterAdapter(router));
89+
NavigationDevTools.register(pageless);
90+
91+
// auto_route
92+
navigatorObservers: () => [adapter.observer, pageless.observer]
93+
```
94+
95+
Both recipes are regression-tested (`dialogs_with_nav1_observer_test.dart` in each adapter package).
96+
97+
## Prior art
98+
99+
- Flutter DevTools ships no navigation/backstack inspector.
100+
- auto_route and go_router ship no DevTools extension (go_router only offers `debugLogDiagnostics` console logging; `developer_tools_auto_route` is an in-app overlay, not a DevTools panel).
101+
102+
## Repository layout
103+
104+
Design docs and implementation plans live in [`docs/superpowers/`](docs/superpowers/). The DevTools panel source is [`packages/navigation_devtools_extension/`](packages/navigation_devtools_extension/) (unpublished; prebuilt into the core package — rebuild with `dart run devtools_extensions build_and_copy --source=. --dest=../navigation_devtools/extension/devtools`).

‎docs/images/panel_go_router.png‎

26.9 KB
Loading

‎docs/images/panel_navigator1.png‎

34.9 KB
Loading

0 commit comments

Comments
 (0)