mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
opt. & fix
This commit is contained in:
@@ -43,6 +43,36 @@ class PersistentStore {
|
||||
boxName,
|
||||
//encryptionCipher: SecureStore._cipher,
|
||||
);
|
||||
|
||||
_StoreProperty<T> property<T>(
|
||||
String key,
|
||||
T defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
}) {
|
||||
return _StoreProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
);
|
||||
}
|
||||
|
||||
_StoreListProperty<T> listProperty<T>(
|
||||
String key,
|
||||
List<T> defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
T Function(dynamic val)? decoder,
|
||||
dynamic Function(T val)? encoder,
|
||||
}) {
|
||||
return _StoreListProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
encoder: encoder,
|
||||
decoder: decoder,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension BoxX on Box {
|
||||
@@ -80,38 +110,6 @@ extension BoxX on Box {
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreX on PersistentStore {
|
||||
_StoreProperty<T> property<T>(
|
||||
String key,
|
||||
T defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
}) {
|
||||
return _StoreProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
);
|
||||
}
|
||||
|
||||
_StoreListProperty<T> listProperty<T>(
|
||||
String key,
|
||||
List<T> defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
T Function(dynamic val)? decoder,
|
||||
dynamic Function(T val)? encoder,
|
||||
}) {
|
||||
return _StoreListProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
encoder: encoder,
|
||||
decoder: decoder,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class StorePropertyBase<T> {
|
||||
ValueListenable<T> listenable();
|
||||
T fetch();
|
||||
|
||||
Reference in New Issue
Block a user