JetStorage class
A unified storage solution for the Jet framework that provides both regular and secure storage capabilities.
This class uses SharedPreferences for regular data storage and FlutterSecureStorage for sensitive data like tokens and passwords.
Example usage:
// Write simple data
await JetStorage.write('username', 'John Doe');
// Read with type safety
String? username = JetStorage.read<String>('username');
// Write complex objects
await JetStorage.write('user', userModel);
// Read with decoder
User? user = JetStorage.read<User>(
'user',
decoder: (json) => User.fromJson(json),
);
Constructors
- JetStorage.new()
-
factory
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
-
clear(
) → Future< bool> - Clears all values from regular storage.
-
clearSecure(
) → Future< void> - Clears all values from secure storage.
-
containsKey(
String key) → bool - Checks if a key exists in storage.
-
delete(
String key) → Future< bool> - Deletes a value from regular storage.
-
deleteSecure(
String key) → Future< void> - Deletes a value from secure storage.
-
getSession(
) → Session? - Gets the current session from storage.
-
init(
) → Future< void> - Initializes the storage system. Must be called before using any storage methods.
-
isLocked(
) → bool - Checks if the app is currently locked.
-
read<
T> (String key, {T decoder(Map< String, dynamic> json)?, T? defaultValue}) → T? - Reads data from regular storage with type safety.
-
readSecure(
String key) → Future< String?> - Reads sensitive data from secure storage.
-
write(
String key, dynamic value) → Future< bool> - Writes data to regular storage.
-
writeSecure(
String key, String value) → Future< void> - Writes sensitive data to secure storage.