17/05/2026
𝐒𝐭𝐨𝐩 𝐰𝐫𝐢𝐭𝐢𝐧𝐠 𝐧𝐚𝐯𝐢𝐠𝐚𝐭𝐢𝐨𝐧 𝐜𝐨𝐝𝐞 𝐦𝐚𝐧𝐮𝐚𝐥𝐥𝐲. 𝐋𝐞𝐭 𝐭𝐡𝐞 𝐦𝐚𝐜𝐡𝐢𝐧𝐞 𝐝𝐨 𝐢𝐭.
If you're using go_router in Flutter (and you probably should be),
you know the drill:
Manually define route paths
Create GoRouter configurations
Write navigation methods
Hope you didn't misspell a route name
𝐄𝐧𝐭𝐞𝐫 𝐭𝐞𝐥𝐞𝐩𝐨𝐫𝐭_𝐫𝐨𝐮𝐭𝐞𝐫_𝐠𝐞𝐧𝐞𝐫𝐚𝐭𝐨𝐫.
It's a code generator that works WITH go_router, not against it. Just add () above your pages, run build_runner, and boom, type-safe routes auto-generated.
𝐖𝐡𝐲 𝐢𝐭'𝐬 𝐚 𝐠𝐚𝐦𝐞-𝐜𝐡𝐚𝐧𝐠𝐞𝐫
1. 𝐓𝐲𝐩𝐞 𝐬𝐚𝐟𝐞𝐭𝐲 𝐚𝐭 𝐜𝐨𝐦𝐩𝐢𝐥𝐞 𝐭𝐢𝐦𝐞
// Before: pray it's correct
context.push('/user/123');
// After: compiler checks everything
UserRoute(userId: '123').teleport(context);
2. 𝐙𝐞𝐫𝐨 𝐛𝐨𝐢𝐥𝐞𝐫𝐩𝐥𝐚𝐭𝐞 𝐧𝐚𝐯𝐢𝐠𝐚𝐭𝐢𝐨𝐧
No more writing the same routing configuration for every page. The generator handles path extraction, query parameters, and extra data automatically
3. 𝐏𝐚𝐫𝐚𝐦𝐞𝐭𝐞𝐫 𝐡𝐚𝐧𝐝𝐥𝐢𝐧𝐠 𝐭𝐡𝐚𝐭 𝐣𝐮𝐬𝐭 𝐰𝐨𝐫𝐤𝐬
Path params, query params, extra data — the generator extracts everything. No manual Uri.parse needed
4. 𝐒𝐡𝐞𝐥𝐥 𝐫𝐨𝐮𝐭𝐞𝐬 𝐬𝐮𝐩𝐩𝐨𝐫𝐭
Need nested navigation with IndexedStack? (isIndexedStack: true) and you're done
𝐐𝐮𝐢𝐜𝐤 𝐬𝐞𝐭𝐮𝐩
dependencies:
teleport_router: ^0.8.5
teleport_router_annotation: ^0.8.5
dev_dependencies:
build_runner: ^2.10.4
teleport_router_generator: ^0.8.2
Then:
()
class HomePage extends StatelessWidget { ... }
Run flutter pub run build_runner build — done.
𝐖𝐡𝐞𝐧 𝐭𝐨 𝐮𝐬𝐞 𝐢𝐭?
Medium to large apps where manual routing becomes chaos
Teams where you want compile-time guarantees
Any app tired of runtime routing errors
The generator creates route classes, parameter extraction, and even provides a global teleportRoutes list for go_router configuration
𝐓𝐡𝐞 𝐛𝐨𝐭𝐭𝐨𝐦 𝐥𝐢𝐧𝐞
teleport_router_generator takes what's good about go_router (declarative routing) and makes it GREAT (type-safe, generated, zero-boilerplate).
Your future self (and your team) will thank you.
Has anyone else tried annotation-based routing in Flutter? What's your setup?