getOperatingSystem static method
获取当前设备的操作系统名称。
Implementation
static Future<String?> getOperatingSystem() async {
try {
if (Platform.isAndroid) {
return "Android";
} else if (Platform.isIOS) {
return "iOS";
} else if (Platform.isMacOS) {
return "macOS";
} else if (Platform.isWindows) {
return "Windows";
} else if (Platform.isLinux) {
return "Linux";
} else {
return "Unknown";
}
} catch (e) {
debugPrint("Failed to get operating system: '${e.toString()}'.");
return null;
}
}