getInt static method

int getInt(
  1. String key, [
  2. int defaultValue = 0
])

Get the data as int.

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 int getInt(String key, [int defaultValue = 0]) {
  if (!isInitialized) {
    debugPrint(
      "It has not been initialized. Please initialize it by executing [initialize()].",
    );
    return 0;
  }
  if (!containsKey(key)) {
    return defaultValue;
  }
  return _preferences?.getInt(key) ?? defaultValue;
}