get static method
Returns the stable device id, generating and persisting one on first use.
Implementation
static Future<String?> get() async {
if (_cached != null) return _cached;
// ── Android: hardware id ───────────────────────────────────────────────
try {
if (Platform.isAndroid) {
_cached = await _androidId.getId();
return _cached;
}
} catch (e) {
debugPrint('CkDeviceId: ANDROID_ID lookup failed: $e');
}
// ── iOS / other: Keychain → SharedPreferences → legacy → generate ─────
_cached = await _readOrCreate();
// Also register with CkStorage.protectKey so that if anyone calls
// CkStorage.deleteAll(), the key is preserved in CkStorage's own cache.
CkStorage.protectKey(_legacyCkStorageKey);
return _cached;
}