set static method
Save the data.
The value
will be saved to the specified key
.
For value
, int, double, String, bool, and List can be specified.
Implementation
static void set(String key, dynamic value) {
if (!isInitialized) {
debugPrint(
"It has not been initialized. Please initialize it by executing [initialize()].",
);
return;
}
assert(value != null, "The value is empty.");
switch (value.runtimeType) {
case int:
_preferences?.setInt(key, value);
break;
case double:
_preferences?.setDouble(key, value);
break;
case String:
_preferences?.setString(key, value);
break;
case bool:
_preferences?.setBool(key, value);
break;
case List:
_preferences?.setStringList(key, value);
break;
}
}