Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Launch App B from App A with arguments

Tags:

flutter

I want Flutter App A to launch Flutter App B passing in arguments.

I want Flutter App B to read these arguments passed by Flutter App A.

How do I do this in Flutter on both iOS & Android?

like image 926
Raj Chaudhary Avatar asked Feb 28 '26 19:02

Raj Chaudhary


1 Answers

if you know the package name you can do handle it this way add this plugins to your 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';
}
}

if you want to check app availability first use flutter_appavailability

If already installed then launch otherwise open link in WebView using url_launcher.

like image 74
griffins Avatar answered Mar 02 '26 14:03

griffins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!