JustSecureStorage class abstract

Interface for sensitive, encrypted key-value storage.

The default implementation is EncryptedFileStorage, which uses AES-256-GCM authenticated encryption with a per-write random nonce and a master key stored in the app's private sandbox. Use this wherever sensitive data (credentials, tokens, PII) must be persisted.

Use JustStorage.encrypted to obtain an instance — no path_provider import required in your app:

final JustSecureStorage secure = await JustStorage.encrypted();

Register in a DI container (e.g. get_it):

sl.registerLazySingleton<JustSecureStorage>(
  () => await JustStorage.encrypted(),
);
Implementers

Constructors

JustSecureStorage()
Default constructor for subclasses.
const

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

clear() Future<void>
Removes all entries from the secure store.
containsKey(String key) Future<bool>
Returns true if an entry for key exists (even if the value is empty).
delete(String key) Future<void>
Removes the entry for key. No-op if the key does not exist.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(String key) Future<String?>
Returns the raw string stored under key, or null if absent.
readAll() Future<Map<String, String>>
Returns all key-value pairs currently in the store as an unmodifiable map.
readJson<T>(String key, T fromJson(Map<String, dynamic> json)) Future<T?>
Reads the stored JSON string for key and deserialises it using fromJson. Returns null if the key is absent or the stored value cannot be parsed.
toString() String
A string representation of this object.
inherited
watch(String key) Stream<String?>
Returns a broadcast Stream that emits:
write(String key, String value) Future<void>
Persists value under key, overwriting any existing entry.
writeJson<T>(String key, T value, Map<String, dynamic> toJson(T value)) Future<void>
Serialises value to JSON using toJson and persists it under key.

Operators

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