checkAvailability static method

Future<AppInfo?> checkAvailability(
  1. String uri
)

Check if an app is available with the given uri scheme.

Returns AppInfo containing info about the App or throws a PlatformException if the app isn't found.

Implementation

static Future<AppInfo?> checkAvailability(String uri) async {
  final args = <String, dynamic>{};
  args.putIfAbsent('uri', () => uri);

  if (Platform.isAndroid) {
    Map<dynamic, dynamic> app = await _channel.invokeMethod(
      "checkAvailability",
      args,
    );

    return AppInfo.fromMap(app);
  } else if (Platform.isIOS) {
    bool appAvailable =
        await _channel.invokeMethod("checkAvailability", args);

    if (!appAvailable) {
      throw PlatformException(code: "", message: "App not found $uri");
    }

    return AppInfo(packageName: uri);
  }

  return null;
}