flutter
runtime_error
ai_generated
true
NavigationError: deep link route not found: /user/profile?id=123
ID: flutter/navigation-deep-link-not-found
85%Fix Rate
85%Confidence
1Evidence
2024-04-12First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Flutter 3.16 | active | — | — | — |
| go_router 12.0.0 | active | — | — | — |
| Navigator 2.0 | active | — | — | — |
Root Cause
The deep link URL does not match any registered route in the Navigator's route table, often due to missing route definition or incorrect path format.
generic中文
深度链接URL与导航器路由表中任何已注册的路由不匹配,通常是由于缺少路由定义或路径格式不正确。
Workarounds
-
95% success Define the route in the router configuration. For go_router: GoRouter(routes: [GoRoute(path: '/user/profile/:id', builder: (context, state) => UserProfilePage(id: state.pathParameters['id']!))])
Define the route in the router configuration. For go_router: GoRouter(routes: [GoRoute(path: '/user/profile/:id', builder: (context, state) => UserProfilePage(id: state.pathParameters['id']!))])
-
85% success If using Navigator 2.0, override the 'onGenerateRoute' method to parse the deep link and return a MaterialPageRoute. Example: onGenerateRoute: (settings) { if (settings.name == '/user/profile') { return MaterialPageRoute(builder: (_) => UserProfilePage(id: settings.arguments as String)); } return null; }
If using Navigator 2.0, override the 'onGenerateRoute' method to parse the deep link and return a MaterialPageRoute. Example: onGenerateRoute: (settings) { if (settings.name == '/user/profile') { return MaterialPageRoute(builder: (_) => UserProfilePage(id: settings.arguments as String)); } return null; } -
80% success Test the deep link with a custom URI scheme: 'myapp://user/profile/123'. Ensure the scheme is registered in Android/iOS and the router handles it.
Test the deep link with a custom URI scheme: 'myapp://user/profile/123'. Ensure the scheme is registered in Android/iOS and the router handles it.
中文步骤
Define the route in the router configuration. For go_router: GoRouter(routes: [GoRoute(path: '/user/profile/:id', builder: (context, state) => UserProfilePage(id: state.pathParameters['id']!))])
If using Navigator 2.0, override the 'onGenerateRoute' method to parse the deep link and return a MaterialPageRoute. Example: onGenerateRoute: (settings) { if (settings.name == '/user/profile') { return MaterialPageRoute(builder: (_) => UserProfilePage(id: settings.arguments as String)); } return null; }Test the deep link with a custom URI scheme: 'myapp://user/profile/123'. Ensure the scheme is registered in Android/iOS and the router handles it.
Dead Ends
Common approaches that don't work:
-
85% fail
go_router and Navigator 2.0 require route patterns with parameter placeholders like '/user/profile/:id', not full URLs.
-
90% fail
Platform-level deep link setup alone is insufficient; the Flutter router must handle the path.
-
75% fail
Deep links often include a host (e.g., 'myapp.com/user/profile'), and the router must match the full path.