Skip to main content
ZICQ

Skills ZICQ category:Agent Workflows flutter-setup-declarative-routing

Flutter Setup Declarative Routing

Configure `MaterialApp.router` using a package like `go_router` for advanced URL-based navigation. Use when developing web applications or mobile apps that require specific deep linking and browser history support.

40736 installs

Official URL:skills.sh

What this skill does

Intro in this page language first. The official description stays in its original wording; we do not rewrite SKILL.md.

What it does

Configure `MaterialApp.router` using a package like `go_router` for advanced URL-based navigation

When to use it

developing web applications or mobile apps that require specific deep linking and browser history support

How agents load it

Per Agent Skills progressive disclosure: name and description load at startup (~100 tokens); the full SKILL.md body loads when the skill activates; scripts/, references/, and assets/ load only as needed. This file's sections: Implementing Routing and Deep Linking; Contents; Core Concepts; Workflow: Initializing the Application and Router; Task Progress; 1. Scaffold the Application. It includes spec-recommended sections: step-by-step instructions.

File analysis

File analysis: instruction-only skill (SKILL.md). The agent loads the full body when activated.

Implementing Routing and Deep LinkingContentsCore ConceptsWorkflow: Initializing the Application and RouterTask Progress1. Scaffold the Application2. Configure the RouterWorkflow: Configuring Platform Deep LinkingTask ProgressIf configuring for Android:If configuring for iOS:Validation Loop

Source category:skills.sh agent-skill

SKILL.md & Agent activation

Official spec ↗
name
flutter-setup-declarative-routing
description
Configure `MaterialApp.router` using a package like `go_router` for advanced URL-based navigation. Use when developing web applications or mobile apps that require specific deep linking and browser history support.
  1. DiscoverThe client exposes names and descriptions to the agent.
  2. ActivateYour request or the task context selects the skill and loads its instructions.
  3. Load resourcesReferenced scripts, documentation and assets are used when needed.

Invocation syntax and available tools depend on your Agent client. Client integration guide ↗

Install this skill

Skills CLI ↗

Choose the target agent and installation scope, keep referenced package files, then verify the skill appears in the client's catalog.

Ask your Agent to install

Copy these instructions to a compatible agent and confirm the target directory matches your client.

Install the agent skill "flutter-setup-declarative-routing" into my project. The full SKILL.md and official description are at https://zicq.com/en/skills/skl-58cb99d98d91001c-Flutter-Setup-Declarative-Routing.html
Save it as .cursor/skills/flutter-setup-declarative-routing/SKILL.md or .claude/skills/flutter-setup-declarative-routing/SKILL.md and keep the frontmatter name and description exactly as-is.

Full package on GitHub ↗

Install from the terminal · Skills CLI

Requires Node.js and npx. First inspect the repository's skill list to confirm the name.

npx skills add 'https://github.com/flutter/agent-plugins' --list

npx skills add 'https://github.com/flutter/agent-plugins' --skill 'flutter-setup-declarative-routing'

The CLI lets you choose the agent interactively. The default scope is the project; use -g for user scope. Confirm package availability with the discovery command, then use npx skills list to inspect installed skills.

Readable layout
--- name: flutter-setup-declarative-routing description: Configure `MaterialApp.router` using a package like `go_router` for advanced URL-based navigation. Use when developing web applications or mobile apps that require specific deep linking and browser history support. metadata: model: models/gemini-3.1-pro-preview last_modified: Tue, 21 Apr 2026 21:08:03 GMT --- # Implementing Routing and Deep Linking ## Contents - [Core Concepts](#core-concepts) - [Workflow: Initializing the Application and Router](#workflow-initializing-the-application-and-router) - [Workflow: Configuring Platform Deep Linking](#workflow-configuring-platform-deep-linking) - [Workflow: Implementing Nested Navigation](#workflow-implementing-nested-navigation) - [Examples](#examples) ## Core Concepts Use the `go_router` package for declarative routing in Flutter. It provides a robust API for complex routing scenarios, deep linking, and nested navigation. - **GoRouter**: The central configuration object defining the application's route tree. - **GoRoute**: A standard route mapping a URL path to a Flutter screen. - **ShellRoute / StatefulShellRoute**: Wraps child routes in a persistent UI shell (e.g., a `BottomNavigationBar`). `StatefulShellRoute` maintains the state of parallel navigation branches. - **Path URL Strategy**: Removes the default `#` fragment from web URLs, essential for clean deep linking across platforms. ## Workflow: Initializing the Application and Router Follow this workflow to bootstrap a new Flutter application with `go_router` and configure the root routing mechanism. ### Task Progress - [ ] Create the Flutter application. - [ ] Add the `go_router` dependency. - [ ] Configure the URL strategy for web/deep linking. - [ ] Implement the `GoRouter` configuration. - [ ] Bind the router to `MaterialApp.router`. ### 1. Scaffold the Application Run the following commands to create the app and add the required routing package: ```bash flutter create cd flutter pub add go_router ``` ### 2. Configure the Router Define a top-level `GoRouter` instance. Handle authentication or state-based routing using the `redirect` parameter. ```dart import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; void main() { // Use path URL strategy to remove the '#' from web URLs usePathUrlStrategy(); runApp(const MyApp()); } final GoRouter _router = GoRouter( initialLocation: '/', routes: [ GoRoute( path: '/', builder: (context, state) => const HomeScreen(), routes: [ GoRoute( path: 'details/:id', builder: (context, state) => DetailsScreen(id: state.pathParameters['id']!), ), ], ), ], errorBuilder: (context, state) => ErrorScreen(error: state.error), ); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp.router( routerConfig: _router, title: 'Routing App', ); } } ``` ## Workflow: Configuring Platform Deep Linking Configure the native platforms to intercept specific URLs and route them into the Flutter application. ### Task Progress - [ ] Determine target platforms (iOS, Android, or both). - [ ] Apply conditional configuration for Android (Manifest + Asset Links). - [ ] Apply conditional configuration for iOS (Plist + Entitlements + AASA). - [ ] Run validator -> review errors -> fix. ### If configuring for Android: 1. **Modify `AndroidManifest.xml`**: Add the intent filter inside the `` tag for `.MainActivity`. ```xml ``` 2. **Host `assetlinks.json`**: Serve the following JSON at `https://yourdomain.com/.well-known/assetlinks.json`. ```json [{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.yourcompany.yourapp", "sha256_cert_fingerprints": ["YOUR_SHA256_FINGERPRINT"] } }] ``` ### If configuring for iOS: 1. **Modify `Info.plist`**: Opt-in to Flutter's default deep link handler. *Note: If using a third-party deep linking plugin (e.g., `app_links`), set this to `NO` to prevent conflicts.* ```xml FlutterDeepLinkingEnabled ``` 2. **Modify `Runner.entitlements`**: Add the associated domain. ```xml com.apple.developer.associated-domains applinks:yourdomain.com ``` 3. **Host `apple-app-site-association`**: Serve the following JSON (without a `.json` extension) at `https://yourdomain.com/.well-known/apple-app-site-association`. ```json { "applinks": { "apps": [], "details": [{ "appIDs": ["TEAM_ID.com.yourcompany.yourapp"], "paths": ["*"], "components": [{"/": "/*"}] }] } } ``` ### Validation Loop Run validator -> review errors -> fix. - **Android**: Test using ADB. ```bash adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://yourdomain.com/details/123"' com.yourcompany.yourapp ``` - **iOS**: Test using `xcrun` on a booted simulator. ```bash xcrun simctl openurl booted https://yourdomain.com/details/123 ``` ## Workflow: Implementing Nested Navigation Use `StatefulShellRoute` to implement persistent UI shells (like a bottom navigation bar) that maintain the state of their child routes. ### Task Progress - [ ] Define `StatefulShellRoute.indexedStack` in the `GoRouter` configuration. - [ ] Create `StatefulShellBranch` instances for each navigation tab. - [ ] Implement the shell widget using `StatefulNavigationShell`. ```dart final GoRouter _router = GoRouter( initialLocation: '/home', routes: [ StatefulShellRoute.indexedStack( builder: (context, state, navigationShell) { return ScaffoldWithNavBar(navigationShell: navigationShell); }, branches: [ StatefulShellBranch( routes: [ GoRoute( path: '/home', builder: (context, state) => const HomeScreen(), ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/settings', builder: (context, state) => const SettingsScreen(), ), ], ), ], ), ], ); ``` ## Examples ### High-Fidelity Shell Widget Implementation Implement the UI shell that consumes the `StatefulNavigationShell` to handle branch switching. ```dart class ScaffoldWithNavBar extends StatelessWidget { const ScaffoldWithNavBar({ required this.navigationShell, super.key, }); final StatefulNavigationShell navigationShell; void _goBranch(int index) { navigationShell.goBranch( index, // Support navigating to the initial location when tapping the active tab. initialLocation: index == navigationShell.currentIndex, ); } @override Widget build(BuildContext context) { return Scaffold( body: navigationShell, bottomNavigationBar: NavigationBar( selectedIndex: navigationShell.currentIndex, onDestinationSelected: _goBranch, destinations: const [ NavigationDestination(icon: Icon(Icons.home), label: 'Home'), NavigationDestination(icon: Icon(Icons.settings), label: 'Settings'), ], ), ); } } ``` ### Programmatic Navigation Use the `context.go()` and `context.push()` extension methods provided by `go_router`. ```dart // Replaces the current route stack with the target route (Declarative) context.go('/details/123'); // Pushes the target route onto the existing stack (Imperative) context.push('/details/123'); // Navigates using a named route and path parameters context.goNamed('details', pathParameters: {'id': '123'}); // Pops the current route context.pop(); ```

Related skills

Agent Workflows

Skill Creator

Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that exte…

Agent Workflows

Clawdhub

Use the ClawdHub CLI to search, install, update, and publish agent skills from clawdhub.com. Use when you need to fetch new skills on the fl…

Agent Workflows

Agent Team Orchestration

Orchestrate multi-agent teams with defined roles, task lifecycles, handoff protocols, and review workflows. Use when: (1) Setting up a team …

Agent Workflows

Superpowers

Spec-first, TDD, subagent-driven software development workflow. Use when: (1) building any new feature or app — triggers brainstorm → plan →…