path method
Get the path of the package with the given packageName.
If the package is not installed, an empty list is returned.
If user is provided, the package path is retrieved for the specified user.
Throws an exception if the package manager command fails.
Example:
final path = await pm.path('com.example.app');
Implementation
Future<List<String>> path(String packageName, {String? user, bool debug = false}) async {
final args = ['pm', 'path'];
if (user != null) {
args.addAll(['--user', user]);
}
args.add(packageName);
final lines = await _shell.exec(args, debug: debug);
final result = <String>[];
lines.stdout.toString().split('\n').forEach((line) {
if (line.startsWith('package:')) {
result.add(line.substring(8).trim());
}
});
return result;
}