LocalStorage class
A wrapper class for session and cache box uses Hive
Properties
- accessToken → String?
-
refreshToken
getter to access accessToken
no setter
- createdAt → DateTime?
-
createdAt
getter to access createdAt
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasSession → bool
-
hasSession
checks whetherBox<Session>
is not empty or Session is not nullno setter - isTokenExpired → bool?
-
isTokenExpired
checks whether token is expired or notno setter -
onSessionChange
→ Stream<
bool> -
onSessionChange
returns stream of bool when data changes on boxno setter - refreshToken → String?
-
refreshToken
getter to access refreshToken
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- updatedAt → DateTime?
-
updatedAt
getter to access updatedAt
no setter
Methods
-
add<
T> ({required String boxName, required T value}) → Future< void> -
add
add data to custom box -
addAll<
T> ({required String boxName, required List< T> values}) → Future<void> -
addAll
add multiple data to custom box -
clear(
) → Future< int> - clear clear all values from box
-
clearAll(
) → Future< void> -
clearAll
clear all values from both session box and cache box
does not clears box created using
openCustomBox()
-
clearSession(
) → Future< void> - clearSession removes the Session value from Box
-
closeAll(
) → Future< void> - close all the opened box
-
delete<
T extends HiveObject> ({required String boxName, required T value, bool filter(T)?}) → Future< void> -
delete
delete item from data -
deleteAll(
) → Future< void> - delete all the opened box
-
get<
T> ({required String key, T? defaultValue, String? boxName}) → T? -
get
get data from cache box returnsdefaultValue
ifkey
is not found returns null ifdefaultValue
is not provided ifboxName
is provided then it will get data from custom box -
getBox<
T> (String name) → Future< Box< T> > -
getBox
returns the previously opened box -
getList<
T> ({required String key, List< T> defaultValue = const []}) → List<T> - getList get list data
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openBox<
T> ({required String boxName, HiveCipher? customCipher, int? typeId}) → FutureOr< Box< T> > -
openBox
open custom box -
put<
T> ({required String key, required T value, String? boxName}) → Future< void> -
put
puts data in cache box ifboxName
is provided then it will put data in custom box -
putAll(
{required Map< String, dynamic> entries}) → Future<void> -
save
puts value in box with
key
-
putList<
T> ({required String key, required List< T> value}) → Future<void> - save list of data
-
remove<
T> ({required String key, String? boxName}) → Future< void> -
remove
removes data from cache box ifboxName
is provided then it will remove data from custom box -
saveToken(
String token, [String? refreshToken]) → Future< void> -
saveToken
updates access token if exists or saves new one if not updates refresh token -
toCacheMap(
) → Map< String, Map< String, dynamic> ?> - convert box to map
-
toString(
) → String -
A string representation of this object.
inherited
-
update<
T extends HiveObject> ({required String boxName, required T value, bool filter(T)?}) → Future< void> -
update
update item from data -
values<
T> (String boxName) → List< T> -
values
get all the values from custom box -
watchKey<
T> ({required String key, String? boxName}) → Stream< T?> - watch watch specific key for value changed
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getInstance(
{void registerAdapters()?, HiveCipher? customCipher}) → Future< LocalStorage> - initialize the dependencies register the adapters
-
readAndClose<
T> ({required String key, required String boxName}) → Future< T?> -
readAndClose
read value from box and close the box -
writeAndClose<
T> ({required String boxName, required String key, required T value}) → Future< void> -
writeAndClose
write value to box and close the box
Constants
- cacheKey → const String
- cache key
- encryptionBoxKey → const String
- encryption key
- sessionKey → const String
- session key