Skip to content

Commit

Permalink
feat(device_info_plus): add major, minor and patch versions to macos (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Apr 5, 2023
1 parent 1af73a6 commit e871e1b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ class _MyAppState extends State<MyApp> {
'arch': data.arch,
'model': data.model,
'kernelVersion': data.kernelVersion,
'majorVersion': data.majorVersion,
'minorVersion': data.minorVersion,
'patchVersion': data.patchVersion,
'osRelease': data.osRelease,
'activeCPUs': data.activeCPUs,
'memorySize': data.memorySize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class MacOsDeviceInfo extends BaseDeviceInfo {
required this.model,
required this.kernelVersion,
required this.osRelease,
required this.majorVersion,
required this.minorVersion,
required this.patchVersion,
required this.activeCPUs,
required this.memorySize,
required this.cpuFrequency,
Expand Down Expand Up @@ -43,6 +46,15 @@ class MacOsDeviceInfo extends BaseDeviceInfo {
/// Operating system release number
final String osRelease;

/// The major release number, such as 10 in version 10.9.3.
final int majorVersion;

/// The minor release number, such as 9 in version 10.9.3.
final int minorVersion;

/// The update release number, such as 3 in version 10.9.3.
final int patchVersion;

/// Number of active CPUs
final int activeCPUs;

Expand All @@ -65,6 +77,9 @@ class MacOsDeviceInfo extends BaseDeviceInfo {
model: map['model'],
kernelVersion: map['kernelVersion'],
osRelease: map['osRelease'],
majorVersion: map['majorVersion'],
minorVersion: map['minorVersion'],
patchVersion: map['patchVersion'],
activeCPUs: map['activeCPUs'],
memorySize: map['memorySize'],
cpuFrequency: map['cpuFrequency'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public class DeviceInfoPlusMacosPlugin: NSObject, FlutterPlugin {
let model = Sysctl.model
let kernelVersion = Sysctl.version
let osRelease = ProcessInfo.processInfo.operatingSystemVersionString
let osVersion = ProcessInfo.processInfo.operatingSystemVersion;
let majorVersion = osVersion.majorVersion
let minorVersion = osVersion.minorVersion
let patchVersion = osVersion.patchVersion
let activeCPUs = Sysctl.activeCPUs
let memorySize = Sysctl.memSize
let cpuFrequency = Sysctl.cpuFreq
Expand All @@ -36,6 +40,9 @@ public class DeviceInfoPlusMacosPlugin: NSObject, FlutterPlugin {
"model": model,
"kernelVersion": kernelVersion,
"osRelease": osRelease,
"majorVersion": majorVersion,
"minorVersion": minorVersion,
"patchVersion": patchVersion,
"activeCPUs": activeCPUs,
"memorySize": memorySize,
"cpuFrequency": cpuFrequency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ void main() {
'cpuFrequency': 2,
'hostName': 'hostName',
'osRelease': 'osRelease',
'majorVersion': 10,
'minorVersion': 9,
'patchVersion': 3,
'computerName': 'computerName',
'kernelVersion': 'kernelVersion',
'systemGUID': null,
Expand All @@ -29,6 +32,9 @@ void main() {
expect(macosDeviceInfo.cpuFrequency, 2);
expect(macosDeviceInfo.hostName, 'hostName');
expect(macosDeviceInfo.osRelease, 'osRelease');
expect(macosDeviceInfo.majorVersion, 10);
expect(macosDeviceInfo.minorVersion, 9);
expect(macosDeviceInfo.patchVersion, 3);
expect(macosDeviceInfo.systemGUID, isNull);
});

Expand Down

0 comments on commit e871e1b

Please sign in to comment.