MMKV constructor
MMKV(})
Get an MMKV instance with an unique ID mmapID
.
- If you want a per-user mmkv, you could merge user-id within
mmapID
. - You can get a multi-process MMKV instance by passing MMKVMode.MULTI_PROCESS_MODE.
- You can encrypt with
cryptKey
, which limits to 16 bytes at most. - You can customize the
rootDir
of the file.
Implementation
MMKV(String mmapID, {MMKVMode mode = MMKVMode.SINGLE_PROCESS_MODE, String? cryptKey, String? rootDir, int expectedCapacity = 0}) {
if (mmapID.isNotEmpty) {
final mmapIDPtr = _string2Pointer(mmapID);
final cryptKeyPtr = _string2Pointer(cryptKey);
final rootDirPtr = _string2Pointer(rootDir);
_handle = _getMMKVWithID(mmapIDPtr, mode.index, cryptKeyPtr, rootDirPtr, expectedCapacity);
calloc.free(mmapIDPtr);
calloc.free(cryptKeyPtr);
calloc.free(rootDirPtr);
}
}