是否可以从另一个Flutter应用程序打开Flutter应用程序的特定屏幕?

s4chpxco  于 2023-03-31  发布在  Flutter
关注(0)|答案(2)|浏览(201)

是否可以从另一个Flutter应用程序打开Flutter应用程序的特定屏幕?

dwbf0jvd

dwbf0jvd1#

你可以在firebase动态链接的帮助下做到这一点。
在应用程序中创建动态链接,并在launch url_launcher的帮助下启动链接
让我们假设2个Flutter应用程序应用程序A和B有N个页面。例如,如果你想从B转到应用程序A的屏幕2
您将从App B上的url_launcher包调用此函数

launch('https://yourapp.page.link/aL7u'); //dynamic link to open the screen.

这将启动一个窗口,将您重定向到该页面
要处理动态链接,请参考此文档。
Flutter动态链接:https://www.filledstacks.com/post/dynamic-links-in-flutter-a-complete-guide/
无上下文导航:https://www.filledstacks.com/post/navigate-without-build-context-in-flutter-using-a-navigation-service/
url_launcherhttps://pub.dev/packages/url_launcher
Firebase动态链接文档:https://firebase.google.com/docs/dynamic-links?authuser=0
注意:要实现这一点,您必须访问这两个应用程序,并应在

hmae6n7t

hmae6n7t2#

是的,有可能!
将此软件包添加到您的pubspec.yaml
flutter_sharing_intent:^1.0.6(https://pub.dev/packages/flutter_sharing_intent
你可以通过这个包裹
现在!你可以打开一些特定的屏幕检查下面的代码

_intentData =
        FlutterSharingIntent.instance.getMediaStream().listen((event) async {

      try {
        if (event.first.value.toString() != "") {
          Navigator.of(context).push(
            MaterialPageRoute(
              builder: (context) => ShareIntentView(
                url: event.first.value.toString(),
              ),
            ),
          );
        }
      } catch (e) {
        debugPrint(e.toString());
      }

      //print("Shared: getMedia ${event.map((f) => f.value).join(",")}");
    });

相关问题