Deep Nesting: Avoid anonymous routes for complex apps; use onGenerateRoute.
Manual String Paths: Always use constants for route names.
Context Leaks: Ensure BuildContext is valid when calling Navigator.of(context). Use ScaffoldMessenger or global keys if navigation is needed outside build.
1---2name: flutter-navigator-v1-imperative3description: Standard Flutter navigation using Navigator 1.0 (push/pop). Use when this capability is needed.4---56# Navigator v1 Navigation78## **Priority: P0 (CRITICAL)**910## Implementation Guidelines1112- **Standard Push**: Use `Navigator.of(context).push(MaterialPageRoute(builder: (_) => Screen()))`.13- **Named Routes**: Define `routes` map in `MaterialApp` or use `onGenerateRoute` for dynamic routing.14- **Passing Arguments**:15 - For named routes: Use `Navigator.pushNamed(context, '/path', arguments: data)`.16 - For `onGenerateRoute`: Extract arguments using `settings.arguments`.17- **Returning Data**: `final result = await Navigator.push(...)` and `Navigator.pop(context, data)`.18- **Replacing Screens**: Use `pushReplacement` or `pushAndRemoveUntil` for auth/splash flows.1920## Code Example2122```dart23// Basic Push24Navigator.push(25 context,26 MaterialPageRoute(builder: (context) => const DetailScreen()),27);2829// Named Routes Configuration30MaterialApp(31 initialRoute: '/',32 onGenerateRoute: (settings) {33 if (settings.name == '/details') {34 final args = settings.arguments as Map;35 return MaterialPageRoute(36 builder: (context) => DetailScreen(id: args['id']),37 );38 }39 return null;40 },41);4243// Navigation with Arguments44Navigator.pushNamed(45 context,46 '/details',47 arguments: {'id': 123},48);49```5051## Anti-Patterns5253- **Deep Nesting**: Avoid anonymous routes for complex apps; use `onGenerateRoute`.54- **Manual String Paths**: Always use constants for route names.55- **Context Leaks**: Ensure `BuildContext` is valid when calling `Navigator.of(context)`. Use `ScaffoldMessenger` or global keys if navigation is needed outside `build`.5657## Reference & Examples5859See [references/on-generate-route.md](references/on-generate-route.md).6061## Related Topics6263idiomatic-flutter | widgets6465---66> Source: [fierzone/agent-skills-standard](https://github.com/fierzone/agent-skills-standard) — distributed by [TomeVault](https://tomevault.io).67<!-- tomevault:4.0:skill_md:2026-06-16 -->
Run npx get-skill add tomevault-io/flutter-navigator-v1-imperative in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Standard Flutter navigation using Navigator 1.0 (push/pop). Use when this capability is needed. It is listed under AI & ML on SkillMD.
SkillMD's automated safety review verdict for this skill is PASS. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.