Analyzed Jul 13, 2026
flutter/agent-plugins · Official
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.
Installation
npx skills add flutter/agent-plugins --skill flutter-setup-declarative-routing
Similar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Browser automation CLI for AI agents. Use when the user needs to interact with websites, includ…
11.9K installsReview UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "chec…
4.7K installsBuild, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and …
1.7K installsPostgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill …
1.4K installsArchitect and provision enterprise Azure infrastructure from workload descriptions. For cloud a…
1.5K installs>- Guides and best practices for working with Lakebase Postgres, the database behind Neon. Cove…
3.2K installsSecurity audits
Partner security reviews for this skill.
Analyzed Jul 13, 2026
Analyzed Jul 13, 2026
0 alerts
Also in this package
Other skills from flutter/agent-plugins · top by installs.
npx skills add flutter/agent-plugins
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Repository health
main
Skill metadata
Parsed from SKILL.md frontmatter.
More metadata
- model
- models/gemini-3.1-pro-preview
- last_modified
- Tue, 21 Apr 2026 21:08:03 GMT
Package contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md8,204 B -
docs
SUMMARY.md255 B
History
- First seen on skills.sh
- First recorded snapshot · 30,408 installs
SKILL.md
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).StatefulShellRoutemaintains 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_routerdependency. - Configure the URL strategy for web/deep linking.
- Implement the
GoRouterconfiguration. - Bind the router to
MaterialApp.router.
1. Scaffold the Application
Run the following commands to create the app and add the required routing package:
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.
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:
- Modify
AndroidManifest.xml: Add the intent filter inside the<activity>tag for.MainActivity.
<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>
- Host
assetlinks.json: Serve the following JSON athttps://yourdomain.com/.well-known/assetlinks.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:
- 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.
<key>FlutterDeepLinkingEnabled</key>
<true/>
- Modify
Runner.entitlements: Add the associated domain.
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:yourdomain.com</string>
</array>
- Host
apple-app-site-association: Serve the following JSON (without a.jsonextension) athttps://yourdomain.com/.well-known/apple-app-site-association.
{
"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
xcrunon 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.indexedStackin theGoRouterconfiguration. - Create
StatefulShellBranchinstances for each navigation tab. - Implement the shell widget using
StatefulNavigationShell.
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.
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.
// 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();