@@ -6,30 +6,27 @@ import '../../sentry_options.dart';
66// Get total & free platform memory (in bytes) for linux and windows operating systems.
77// Source: https://github.com/onepub-dev/system_info/blob/8a9bf6b8eb7c86a09b3c3df4bf6d7fa5a6b50732/lib/src/platform/memory.dart
88class PlatformMemory {
9- PlatformMemory (this .operatingSystem, this . options);
9+ PlatformMemory (this .options);
1010
11- final String operatingSystem;
1211 final SentryOptions options;
1312
1413 int ? getTotalPhysicalMemory () {
15- switch (operatingSystem) {
16- case 'linux' :
17- return _getLinuxMemInfoValue ('MemTotal' );
18- case 'windows' :
19- return _getWindowsWmicValue ('ComputerSystem' , 'TotalPhysicalMemory' );
20- default :
21- return null ;
14+ if (options.platformChecker.platform.isLinux) {
15+ return _getLinuxMemInfoValue ('MemTotal' );
16+ } else if (options.platformChecker.platform.isWindows) {
17+ return _getWindowsWmicValue ('ComputerSystem' , 'TotalPhysicalMemory' );
18+ } else {
19+ return null ;
2220 }
2321 }
2422
2523 int ? getFreePhysicalMemory () {
26- switch (operatingSystem) {
27- case 'linux' :
28- return _getLinuxMemInfoValue ('MemFree' );
29- case 'windows' :
30- return _getWindowsWmicValue ('OS' , 'FreePhysicalMemory' );
31- default :
32- return null ;
24+ if (options.platformChecker.platform.isLinux) {
25+ return _getLinuxMemInfoValue ('MemFree' );
26+ } else if (options.platformChecker.platform.isWindows) {
27+ return _getWindowsWmicValue ('OS' , 'FreePhysicalMemory' );
28+ } else {
29+ return null ;
3330 }
3431 }
3532
0 commit comments