getInstalledApplications static method

Future<List<Application>> getInstalledApplications({
  1. bool includeSystemApps = false,
  2. bool includeAppIcons = false,
  3. bool onlyAppsWithLaunchIntent = false,
})

List installed applications on the device includeSystemApps will also include system apps (or pre-installed) like Phone, Settings... includeAppIcons will also include the icon for each app (be aware that this feature is memory-heaving, since it will load all icons). To get the icon you have to cast the object to ApplicationWithIcon onlyAppsWithLaunchIntent will only list applications when an entrypoint. It is similar to what a launcher will display

Implementation

static Future<List<Application>> getInstalledApplications({
  bool includeSystemApps: false,
  bool includeAppIcons: false,
  bool onlyAppsWithLaunchIntent: false,
}) async {
  try {
    final Object apps =
        await _methodChannel.invokeMethod('getInstalledApps', <String, bool>{
      'system_apps': includeSystemApps,
      'include_app_icons': includeAppIcons,
      'only_apps_with_launch_intent': onlyAppsWithLaunchIntent
    });

    if (apps is Iterable) {
      List<Application> list = <Application>[];
      for (Object app in apps) {
        if (app is Map) {
          try {
            list.add(Application._(app));
          } catch (e, trace) {
            if (e is AssertionError) {
              print('[DeviceApps] Unable to add the following app: $app');
            } else {
              print('[DeviceApps] $e $trace');
            }
          }
        }
      }
      return list;
    } else {
      return List<Application>.empty();
    }
  } catch (err) {
    print(err);
    return List<Application>.empty();
  }
}