Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

flutter-setup-declarative-routing — Claude Code Flutter skill

Sets up Flutter routing with go_router, including URL-based screens, nested navigation, and deep links for web and mobile apps.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add flutter/agent-plugins --skill flutter-setup-declarative-routing -a claude-code
Open on GitHub

What flutter-setup-declarative-routing does

The skill shows how to connect GoRouter to MaterialApp.router, map paths to screens, and pass path parameters such as an item ID. For web apps, it removes the # fragment from URLs. Its nested navigation example uses StatefulShellRoute to keep branch state, such as the state of each bottom-navigation tab.

For Android deep links, the guide covers AndroidManifest.xml and assetlinks.json; for iOS, it covers Info.plist, Runner.entitlements, and apple-app-site-association. It also includes checks with adb and xcrun. On iOS, a plugin such as app_links can conflict with Flutter's default deep-link handler, so check the FlutterDeepLinkingEnabled setting before using both.

The project needs the go_router package, which the guide adds with flutter pub add go_router. It also covers redirects based on app state and route error handling. Platform setup uses your domain and app identifiers, plus a signing fingerprint for Android.

What it helps with

  • map Flutter screens to URL paths
  • pass a path parameter to a details screen
  • remove # fragments from web app URLs
  • configure Android and iOS deep links
  • retain tab state across navigation branches

Example prompts for the agent

  • Configure `go_router` in this Flutter project with `/` and `/details/:id` routes.
  • Set up Android deep links and check the URL with `adb`.
  • Build tab navigation with `StatefulShellRoute` and keep each branch's state.

How to install flutter-setup-declarative-routing

1Skills CLI (Vercel)

npx skills add flutter/agent-plugins --skill flutter-setup-declarative-routing -a claude-code

2Manually: put the files in place

~/.claude/skills/flutter-setup-declarative-routing/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/flutter-setup-declarative-routing/

From the same set14

The whole set →
flutter-apply-architecture-best-practices flutter This skill structures Flutter apps around UI, Logic, and Data layers. Use it when starting a project or refactoring code for scale. Claude Code CX Codex Cursor +1 43,000installs flutter-build-responsive-layout flutter This skill guides coding agents to build adaptive Flutter UIs across mobile and desktop screens using LayoutBuilder and BoxConstraints. Claude Code CX Codex Cursor +1 42,300installs flutter-add-widget-test flutter A skill that teaches AI coders to write component-level Flutter tests using WidgetTester. Verifies how widgets render and respond to taps, scrolling, and text input. Claude Code CX Codex Cursor +1 39,000installs flutter-add-integration-test flutter Sets up the integration_test package for Flutter and turns MCP session interactions into repeatable end-to-end tests. Claude Code CX Codex Cursor +1 38,000installs flutter-implement-json-serialization flutter Teaches coding agents to build Dart models with fromJson and toJson methods using dart:convert. Useful for manual JSON mapping in simple Flutter data structures. Claude Code CX Codex Cursor +1 37,200installs flutter-add-widget-preview flutter Configures interactive Flutter widget previews with package:flutter/widget_previews.dart. Useful for testing UI components in isolation without launching the whole app. Claude Code CX Codex Cursor +1 36,600installs flutter-setup-localization flutter This skill automates initialization of multi-language support in Flutter projects. It adds dependencies, enables code generation, and creates a configuration file for .arb-based translations. Claude Code CX Codex Cursor +1 36,600installs flutter-use-http-package flutter This skill shows how to send GET, POST, PUT, and DELETE requests with Flutter's http package and handle JSON responses. Use it when an app needs to read from or write to a REST API. Claude Code CX Codex Cursor +1 36,000installs

Similar

google-mobile-ads-banner official google This skill guides banner ad setup with Google Mobile Ads in Android, iOS, and Unity apps. Use it when the task is limited to banner advertising. Claude Code Gemini CLI CX Codex 5,818installs google-mobile-ads-interstitial official google Guides Google Mobile Ads interstitial setup in Android, iOS, and Unity apps. Use it when you need full-page ads between app content. Claude Code Gemini CLI CX Codex 5,816installs google-mobile-ads-rewarded official google This skill guides Google Mobile Ads rewarded ad setup for Android, iOS, and Unity. Use it when users opt in to watch an ad for an in-app reward. Claude Code Gemini CLI CX Codex 5,814installs msstore-cli official github Manages Windows app publishing in Microsoft Store through msstore and Partner Center. Use it for submissions, release status checks, and CI/CD publishing. GitHub Copilot 7,000installs expo-module expo Complete reference for building native modules and view components in Swift, Kotlin, and TypeScript for Expo apps. Use when writing a new module or adding native functionality—camera, sensors, system APIs. Claude Code CX Codex Cursor +1 44,900installs vercel-react-native-skills vercel A rules pack for React Native and Expo work: lists, animations, navigation, native modules. Load it so your agent makes mobile changes the same way every time. Claude Code CX Codex Cursor +1 253,900installs animate-expo emilkowalski Builds React Native and Expo animations using Reanimated and Gesture Handler. Helps keep motion on the UI thread and avoid dropped frames on physical devices. Claude Code CX Codex Cursor +1 135,900installs mobile-native emilkowalski Strips the tells that give a web app away on a phone: sticky hover, tap highlight flash, the 100vh bug. Claude Code CX Codex Cursor +1 84,500installs

Questions about flutter-setup-declarative-routing

How do I install flutter-setup-declarative-routing in Claude Code?

Run npx skills add flutter/agent-plugins --skill flutter-setup-declarative-routing -a claude-code. The skill file is at ~/.claude/skills/flutter-setup-declarative-routing/SKILL.md.

What does flutter-setup-declarative-routing do?

It guides setup of Flutter routing with go_router, covering URL paths, deep links, and nested navigation that preserves branch state.

What should I check when configuring iOS deep links?

The guide covers Info.plist, Runner.entitlements, and apple-app-site-association. If the app uses a plugin such as app_links, coordinate it with FlutterDeepLinkingEnabled to avoid a handler conflict.

Source text

SKILL.md · BSD-3-Clause
---
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 <app-name>
cd <app-name>
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 `<activity>` tag for `.MainActivity`.
```xml
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" android:host="yourdomain.com" />
    <data android:scheme="https" />
</intent-filter>
```
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
<key>FlutterDeepLinkingEnabled</key>
<true/>
```
2. **Modify `Runner.entitlements`**: Add the associated domain.
```xml
<key>com.apple.developer.associated-domains</key>
<array>
  <string>applinks:yourdomain.com</string>
</array>
```
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();
```

© flutter · BSD-3-Clause · flutter/agent-plugins

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor