get<T> static method

T get<T>(
  1. String key,
  2. T defaultValue
)

Get the data.

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 T get<T>(String key, T defaultValue) {
  if (!isInitialized) {
    throw Exception(
      "It has not been initialized. Please initialize it by executing [initialize()].",
    );
  }
  if (!containsKey(key)) {
    return defaultValue;
  }
  return _preferences?.get(key) as T ?? defaultValue;
}