npx skills add ...
npx skills add flutter/agent-plugins --skill flutter-setup-declarative-routing
npx skills add flutter/agent-plugins --skill 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.
The same skill content is published under more than one repo. The install counts are split across them; any of these commands works.
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:
Define a top-level GoRouter instance. Handle authentication or state-based routing using the redirect parameter.
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.assetlinks.json: Serve the following JSON at https://yourdomain.com/.well-known/assetlinks.json.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.Runner.entitlements: Add the associated domain.apple-app-site-association: Serve the following JSON (without a .json extension) at https://yourdomain.com/.well-known/apple-app-site-association.Run validator -> review errors -> fix.
xcrun on a booted simulator.
Use 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.Implement the UI shell that consumes the StatefulNavigationShell to handle branch switching.
Use the context.go() and context.push() extension methods provided by go_router.
<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>[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.yourcompany.yourapp",
"sha256_cert_fingerprints": ["YOUR_SHA256_FINGERPRINT"]
}
}]<key>FlutterDeepLinkingEnabled</key>
<true/><key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:yourdomain.com</string>
</array>{
"applinks": {
"apps": [],
"details": [{
"appIDs": ["TEAM_ID.com.yourcompany.yourapp"],
"paths": ["*"],
"components": [{"/": "/*"}]
}]
}
}