Cache class

Cache is a 'shared_preferences' wrapper to store and retrieve cache String using keyPrefix.key as key format.

Provide index support

Constructors

Cache({String keyPrefix = 'indexedCache', dynamic saveWaitAgainSeconds = 2, dynamic saveWaitSeconds = 2})

Properties

debugLog bool
getter/setter pair
debugLogJson bool
enable/disable fromJson debug log
getter/setter pairinherited
debugLogJsonContent bool
enable/disable fromJson debug log with content
getter/setter pairinherited
debugLogSave bool
enable/disable save debug log
getter/setter pairinherited
filenamePrefix String
Filename prefix when generating filename from keyFilename.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
index List<String>
Return index as List<String>
no setter
key String
key for saving preference
finalinherited
keyFilename → dynamic
Generate filename from key
no setterinherited
keyPrefix String
keyPrefix is part of storage key.
final
lastSaveTime DateTime
Return preference last save time
no setterinherited
obj Map<String, dynamic>
JSON object holding all preferences
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
saveWaitAgainSeconds int
If save requested came in during wait, number of seconds to wait again
getter/setter pairinherited
saveWaitSeconds int
Number of seconds before actually trying to save
getter/setter pairinherited

Methods

clear() Future
Remove all entries with keyPrefix from local storage
fromJson(Map<String, dynamic> jsonObj, {bool debug = false}) → void
Apply/Clone from json object
inherited
get(String key) Future<String>
Get entry with key from local storage
getPref() FutureOr<SharedPreferences>
Return cached SharedPreferences instance
inherited
load({bool forced = false}) Future<void>
load preference from local storage
inherited
noSave(Function function) → void
No-save wrapper
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String key) Future
Remove entry with key from local storage
save({DateTime? dateTime, Function? saved, String debugMsg = '', bool noSaveTime = false}) Future<void>
Save preference to local storage
inherited
set(String key, String data) Future
Add/Set entry with key = data in local storage
toJson() Map<String, dynamic>
Return a deep copy json object
inherited
toString() String
Return pretty print json
inherited

Operators

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