getString static method

String getString(
  1. String key, [
  2. String defaultValue = ""
])

Get the data as String.

Specify the key of the value you want to get for key.

If the value does not exist in the specified key, the value of defaultValue will be returned.

Implementation

static String getString(String key, [String defaultValue = ""]) {
  if (!isInitialized) {
    debugPrint(
      "It has not been initialized. Please initialize it by executing [initialize()].",
    );
    return "";
  }
  if (!containsKey(key)) {
    return defaultValue;
  }
  return _preferences?.getString(key) ?? defaultValue;
}