31 skills · 85 min
Skills
Skill 23 of 31
Configure MaterialApp.router using a package like go_router for advanced URL-based navigation.
2 minutes · 373 words · 17 sections
Install
npx skills add flutter/agent-plugins --skill flutter-setup-declarative-routingnpx skills add flutter/agent-plugins/plugin marketplace add flutter/agent-pluginsThe first command installs just this skill, by the name in its SKILL.md; the second installs the whole repository.
Use the go_router package for declarative routing in Flutter. It provides a robust API for complex routing scenarios, deep linking, and nested navigation.
BottomNavigationBar). StatefulShellRoute maintains the state of parallel navigation branches.# fragment from web URLs, essential for clean deep linking across platforms.Follow this workflow to bootstrap a new Flutter application with go_router and configure the root routing mechanism.
go_router dependency.GoRouter configuration.MaterialApp.router.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_routerDefine 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
Configure the native platforms to intercept specific URLs and route them into the Flutter application.
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" />
assetlinks.json: Serve the following JSON at https://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"]
}
}]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/>Runner.entitlements: Add the associated domain.<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:yourdomain.com</string>
</array>apple-app-site-association: Serve the following JSON (without a .json extension) at https://yourdomain.com/.well-known/apple-app-site-association.{
"applinks": {
"apps": [],
"details": [{
"appIDs": ["TEAM_ID.com.yourcompany.yourapp"],
"paths": ["*"],
"components": [{"/": "/*"}]
}]
}
}Run validator -> review errors -> fix.
adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://yourdomain.com/details/123"' com.yourcompany.yourappxcrun on a booted simulator.
xcrun simctl openurl booted https://yourdomain.com/details/123Use StatefulShellRoute to implement persistent UI shells (like a bottom navigation bar) that maintain the state of their child routes.
StatefulShellRoute.indexedStack in the GoRouter configuration.StatefulShellBranch instances for each navigation tab.StatefulNavigationShell.final GoRouter _router = GoRouter(
initialLocation: '/home',
routes: [
StatefulShellRoute.indexedStack(
builder: (context, state, navigationShell) {
return ScaffoldWithNavBar(navigationShell: navigationShell);
},
branches
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
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();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.
The verbatim description from this skill’s front matter — the string an agent matches on to decide whether to load it.
main, last pushed 17 September 2026.SKILL.md, not by matching a directory convention. 2 distinct layouts observed: .agents/agents/reidbaker-agent/skills/*/SKILL.md, skills/*/SKILL.md.h1 and no skipped levels:.claude-plugin/marketplace.json by Dart and Flutter Team, declaring 1 plugin. It is read for editorial metadata only — never as the skill index, which is always the repository tree./flutter/agent-plugins.md, and each skill at its own .md URL.