getValue method

Future<T?> getValue(
  1. SharedPreferencesAsync prefs
)

Gets the value from SharedPreferences.

If the value doesn't exist and defaultValue is provided, stores the default value and returns it.

Implementation

Future<T?> getValue(SharedPreferencesAsync prefs) async {
  final value = await adapter.getter(prefs, key);
  if (value == null && defaultValue != null) {
    await setValue(prefs, defaultValue as T);
    return defaultValue;
  }
  return value;
}