openDirectory static method
dynamic
openDirectory(
- String? path
)
Implementation
static openDirectory(String? path) async {
final dir = path ?? '.';
ColoredLog.white('Opening directory at $dir');
try {
if (Platform.isWindows) {
await Process.run('explorer', [dir]);
} else if (Platform.isMacOS) {
await Process.run('open', [dir]);
} else if (Platform.isLinux) {
await Process.run('xdg-open', [dir]);
} else {
ColoredLog.red(
'Unsupported platform for opening file explorer',
name: 'Failed',
);
throw 'Unsupported platform';
}
} catch (e) {
throw 'Failed to open directory';
}
}