Flutter:使用参数从应用程序A启动应用程序B

时间:2020-05-07 05:02:38

标签: flutter

我希望Flutter App A启动Flutter App B并传递参数。

我希望Flutter App B读取Flutter App A传递的这些参数。

如何在iOS和Android上的Flutter中执行此操作?

1 个答案:

答案 0 :(得分:0)

如果您知道软件包名称,则可以通过这种方式进行处理 将此插件添加到您的pubspec

 device_apps:
android_intent:
url_launcher:

openAnotherApp (data) async
{String dt = data['hello there'] as String;
  bool isInstalled = await DeviceApps.isAppInstalled('com.another app');
if (isInstalled != false)
 {
    AndroidIntent intent = AndroidIntent(
      action: 'action_view',
      data: dt
  );
  await intent.launch();
 }
else
  {
  String url = dt;
  if (await canLaunch(url)) 
    await launch(url);
   else 
    throw 'Could not launch $url';
}
}

如果您想检查应用程序的可用性,请先使用flutter_appavailability

如果已安装,则使用url_launcher启动WebView中的打开链接。