listInstalledApps method
Implementation
@override
Future<List<InstalledApp>> listInstalledApps() async {
// Use mdfind (Spotlight) to list apps
final apps = <InstalledApp>[];
try {
final result = await Process.run('mdfind', [
'kMDItemContentType == "com.apple.application-bundle"',
]);
if (result.exitCode == 0) {
final lines = (result.stdout as String).trim().split('\n');
for (final line in lines) {
if (line.isEmpty) continue;
final name = p.basenameWithoutExtension(line);
// Get bundle ID via mdls
try {
final mdls = await Process.run('mdls', [
'-name',
'kMDItemCFBundleIdentifier',
'-raw',
line,
]);
final bundleId = (mdls.stdout as String).trim();
if (bundleId != '(null)' && bundleId.isNotEmpty) {
apps.add(
InstalledApp(bundleId: bundleId, displayName: name, path: line),
);
}
} catch (_) {}
}
}
} catch (_) {}
return apps;
}