>>108618360
this was here patch for utils import 'dart:io';
class Utils {
/// Checks if a command is installed, using 'where' on Windows and 'which' on others.
Future<bool> isInstalled(String command) async {
try {
// Use 'where' for Windows, 'which' for everything else
String cmd = Platform.isWindows ? 'where' : 'which';
ProcessResult result = await Process.run(cmd, [command]);
return result.exitCode == 0;
} catch (_) {
return false;
}
}
/// Returns the path to a command, handling Windows 'where' vs Unix 'which'.
Future<String?> whichPath(String command) async {
try {
String cmd = Platform.isWindows ? 'where' : 'which';
ProcessResult result = await Process.run(cmd, [command]);
if (result.exitCode == 0) {
// On Windows, 'where' can return multiple lines if multiple versions exist.
// We only want the first (most relevant) path.
String output = (result.stdout as String).trim();
return output.split('\n')[0].trim();
}
return null;
} catch (_) {
return null;
}
}
bool getBool({required String key, required Map<String, dynamic> map, required bool def}) {
var value = map[key];
if (value is bool) {
return value;
}
if (value is String) {
value = bool.tryParse(value);
}
if (value == null) {
return def;
}
return value;
}
int getInt({required String key, required Map<String, dynamic> map, required int def}) {
var value = map[key];
if (value is int) {
return value;
}
if (value is String) {
value = int.tryParse(value);
}
if (value == null) {
return def;
}
return value;
}
}
im not sure it will work without that even when setting the path with the launch option it checks if it exists using which