我正在try 添加一个动作扩展到我的Flutter应用程序.我打算使用动作发送一个图像到我的应用程序. Go Router用于路由在我的应用程序中,所以我必须使用Go Router进行深度链接. 由于我的应用程序的复杂性,我需要导航到嵌套路径.
一切看起来都是应该的,但我面临着一些意想不到的行为.
操作扩展或xcrun simctl openurl booted <url>
命令打开应用程序,但没有导航正确的路径.redirect
在从扩展或命令提示符打开时不调用.
这是我的路由配置
final _router = GoRouter(
redirect: (context, state) {
print(state);
return null;
},
routes: [
GoRoute(
path: '/',
builder: (context, state) => const MyHomePage(),
),
GoRoute(path: '/first', builder: (context, state) => const FirstScreen(), routes: [
GoRoute(
path: 'image-capture',
builder: (context, state) => const ImageDart(),
),
]),
],
);
下面是info.plist中的自定义URL方案部分
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.bahadirarslan.goRouterDeeplink</string>
<key>CFBundleURLSchemes</key>
<array>
<string>gorouterapp</string>
</array>
</dict>
</array>
我try 了下面的命令来调用路由
xcrun simctl openurl booted gorouterapp://com.bahadirarslan.goRouterDeeplink/first
xcrun simctl openurl booted gorouterapp://com.bahadirarslan.goRouterDeeplink/first/image
xcrun simctl openurl booted gorouterapp://first/image
xcrun simctl openurl booted gorouterapp://a/first/image
xcrun simctl openurl booted gorouterapp:/first/image
上面的命令都没有打开任何路径,除了主屏幕.
另外,我知道有this issue张唱片,但这个问题已经结束了,但我仍然无法弄清楚这项工作的变化或影响.
为了简化,我创建了一个示例应用程序,其行为如上所述.我希望你能告诉我,我的错误.