Create a button to open another app in Flutter

I would like to create a simple app in Flutter that contains for example 3 button , the event onPressed in the button should open another external app , is that possible in Flutter and how should I proceed?

Upvotes: 0

Views: 5907

Answers (2)

CopsOnRoad
CopsOnRoad

Reputation: 267484

You can use Column/Row to create your buttons. And after that you can simply use a RaisedButton like this:

ElevatedButton(
  onPressed: () {
    // use android_intent package to open other app
    final intent = AndroidIntent(package: "com.android.facebook", action: "action_view");
    intent.launch();
  },
  child: Text("Open Facebook")
)

It's easy to do it in Android using android_intent_plus and for iOS you can do it natively, this will help you.

Upvotes: 2

Swapnil Chaudhari
Swapnil Chaudhari

Reputation: 542

In my case action: "action_view" caused app selection dialog getting opened. We can open specific component using below.

You can try android_intent library for launching external app. Documentation has some sample codes. You may use sample code below.

var map={"AuthParams":authParam};
var intent=AndroidIntent(package:"in.app",arguments: map,componentName: "in.app.ui.splash.SplashActivity",/*action: "action_view"*/);
await intent.launch();

Upvotes: 0

Related Questions