write method
Future<void>
write({
- required String key,
- required String? value,
- AppleOptions? iOptions,
- AndroidOptions? aOptions,
- LinuxOptions? lOptions,
- WebOptions? webOptions,
- AppleOptions? mOptions,
- WindowsOptions? wOptions,
Encrypts and saves the key with the given value.
If the key was already in the storage, its associated value is changed.
If the value is null, deletes associated value for the given key.
key shouldn't be null.
value required value
iOptions optional iOS options
aOptions optional Android options
lOptions optional Linux options
webOptions optional web options
mOptions optional MacOs options
wOptions optional Windows options
Can throw a PlatformException.
Implementation
Future<void> write({
required String key,
required String? value,
AppleOptions? iOptions,
AndroidOptions? aOptions,
LinuxOptions? lOptions,
WebOptions? webOptions,
AppleOptions? mOptions,
WindowsOptions? wOptions,
}) async {
if (value == null) {
await _platform.delete(
key: key,
options: _selectOptions(
iOptions,
aOptions,
lOptions,
webOptions,
mOptions,
wOptions,
),
);
} else {
await _platform.write(
key: key,
value: value,
options: _selectOptions(
iOptions,
aOptions,
lOptions,
webOptions,
mOptions,
wOptions,
),
);
}
_callListenersForKey(key, value);
}