launchApp method

Future<String?> launchApp(
  1. String packageName, {
  2. bool forceAppStore = false,
})

This method launches an app by its packageName on device and if it's not installed it will launch them on play store or the browser depending on if google play store is installed.

Note that you can set forceAppStore to true if you want to force
the app to open on google play store for example if you want users to rate your app.

Implementation

Future<String?> launchApp(
  String packageName, {
  bool forceAppStore = false,
}) async {
  assert(packageName.isNotEmpty, "packageName can not be empty");
  try {
    String? launchResult = await _channel.invokeMethod(
      "launchApp",
      {"packageName": packageName, "forceAppStore": forceAppStore},
    );
    return launchResult;
  } on PlatformException catch (e) {
    throwError(e, "opening $packageName");
    return "FailedToOpen";
  }
}