getApp static method

Future<Application?> getApp(
  1. String packageName, [
  2. bool includeAppIcon = false
])

Provide all information for a given app by its packageName includeAppIcon will also include the icon for the app. To get it, you have to cast the object to ApplicationWithIcon.

Implementation

static Future<Application?> getApp(
  String packageName, [
  bool includeAppIcon = false,
]) async {
  if (packageName.isEmpty) {
    throw Exception('The package name can not be empty');
  }
  try {
    final Object? app = await _methodChannel.invokeMethod(
        'getApp', <String, Object>{
      'package_name': packageName,
      'include_app_icon': includeAppIcon
    });

    if (app != null && app is Map<dynamic, dynamic>) {
      return Application._(app);
    } else {
      return null;
    }
  } catch (err) {
    print(err);
    return null;
  }
}