CkDeviceId class abstract

A stable per-device identifier that survives app uninstall/reinstall.

  • Android: Settings.Secure.ANDROID_ID. Survives reinstall; only resets on factory reset or a change of app signing key.

  • iOS: A UUID generated once and persisted directly in the Keychain via a dedicated FlutterSecureStorage instance with KeychainAccessibility.first_unlock. The iOS Keychain survives app uninstall/reinstall (the item persists on disk and becomes accessible again when the same bundle-ID / team is reinstalled).

    A backup copy is also kept in SharedPreferences (which does NOT survive uninstall) so that if the Keychain read ever fails transiently, the id can still be recovered within the same install session.

Why not go through CkStorage?

CkStorage has a 3-second timeout on its readAll() warm-up. If the Keychain is slow (cold boot, first launch after OS update, etc.), the timeout fires and CkStorage silently falls back to SharedPreferences. When the device id is written there instead of the Keychain, it is lost on uninstall. By using a dedicated FlutterSecureStorage instance for just this one key, we avoid that timeout entirely and guarantee the id is always written to the Keychain.

Usage: final id = await CkDeviceId.get();

Constructors

CkDeviceId()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

get() Future<String?>
Returns the stable device id, generating and persisting one on first use.