getInstalledApps method

  1. @override
Future<List<Map<String, dynamic>>> getInstalledApps({
  1. String appType = 'all',
  2. bool includeIcons = false,
})
override

Get all installed apps.

Implementation

@override
Future<List<Map<String, dynamic>>> getInstalledApps({
  String appType = 'all',
  bool includeIcons = false,
}) async {
  try {
    final dynamic rawResult = await methodChannel.invokeMethod(
      'getInstalledApps',
      {
        'appType': appType,
        'includeIcons': includeIcons,
      },
    );

    if (rawResult is! List) {
      throw Exception('Expected List but got ${rawResult.runtimeType}');
    }

    return rawResult.map((dynamic item) {
      if (item is! Map) {
        throw Exception('Expected Map but got ${item.runtimeType}');
      }
      return Map<String, dynamic>.from(item);
    }).toList();
  } on PlatformException catch (e) {
    throw Exception('Failed to get installed apps: ${e.message}');
  }
}