checkOSVersion function

bool checkOSVersion({
  1. Version? iOS,
  2. Version? macOS,
})

Returns whether the current MacOS/iOS version is greater than or equal to the given version.

Designed to replace Objective-C's @available check.

The each platform's version is optional, and the function returns false if no version is provided for the current platform.

Implementation

bool checkOSVersion({Version? iOS, Version? macOS}) {
  if (Platform.isIOS) return _checkOSVersionImpl(iOS);
  if (Platform.isMacOS) return _checkOSVersionImpl(macOS);
  throw UnsupportedError('Only supported on iOS and macOS');
}