ensureInitialized static method

void ensureInitialized()

Ensures platform info is initialized.

Called automatically by property accessors - no need to call manually. Safe to call multiple times.

Implementation

static void ensureInitialized() {
  if (_isInitialized) return;

  try {
    if (Platform.isIOS) {
      _cachedIOSVersion = _getIOSVersionManually();
      debugPrint(
        '✅ [cupertino_native_better] iOS version detected: $_cachedIOSVersion',
      );
    } else if (Platform.isMacOS) {
      _cachedMacOSVersion = _getMacOSVersionManually();
      debugPrint(
        '✅ [cupertino_native_better] macOS version detected: $_cachedMacOSVersion',
      );
    }
  } catch (e) {
    debugPrint('⚠️ [cupertino_native_better] Failed to get OS version: $e');
    // On error, assume recent version (iOS 26+ supports Liquid Glass)
    if (Platform.isIOS) {
      _cachedIOSVersion = 26; // Assume modern iOS
    } else if (Platform.isMacOS) {
      _cachedMacOSVersion = 26; // Assume modern macOS
    }
  }

  _isInitialized = true;
}