MyStorage class

本应用专用 GetStorage 容器。

无容器名的 GetStorage() 会写成用户「文档」下的 GetStorage.gs, 桌面端所有同样用法的应用共享该文件。xly 内部(浮窗位置等)必须走命名容器。

业务代码请用 box,不要再写 GetStorage()

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 Properties

box GetStorage
本应用命名容器。须先 ensureInitializedMyApp.initialize 会调)。
no setter
containerName String
no setter
isReady bool
当前容器是否已由 ensureInitialized 就绪。
no setter

Static Methods

debugReset() → void
测试用:清掉单例状态。不影响 get_storage 进程内缓存。
ensureInitialized({String? storageContainer, String? appName, String? packageName}) Future<void>
解析并初始化命名容器;必要时从共享默认盒迁走 _xly_* 键。
isOwnedKey(String key) bool
xly 内部键:_xly_ 前缀。不认领业务键,避免从共享文件误搬走别人的数据。
keysOf(GetStorage box) List<String>
migrateOwnedKeys({required List<String> sourceKeys, required dynamic readSource(String key), required dynamic readDest(String key), required Future<void> writeDest(String key, dynamic value), required Future<void> removeSource(String key)}) Future<int>
可单测的迁移核:只拷 isOwnedKey 为真且目标尚未有值的键,再从源删除。
migrateXlyKeysFromDefault({GetStorage? source, GetStorage? destination}) Future<int>
仅迁移本库拥有的键;其它应用的数据留在默认容器。
resolveContainerName({String? storageContainer, String? appName, String? packageName}) String
容器名优先级:显式 storageContainerappNamepackageName → 兜底。 默认共享名 GetStorage 会被拒绝,以免又写回 GetStorage.gs
sanitizeContainerName(String? raw) String?
去掉 Windows 非法文件名字符;空串或 GetStorage 视为无效。

Constants

fallbackContainerName → const String
未提供 appName / packageName / storageContainer 时的兜底。
migratedFlagKey → const String
sharedContainerName → const String
get_storage 默认容器名,对应共享文件 GetStorage.gs