read method

dynamic read(
  1. String key
)

Implementation

dynamic read(String key) {
  String? storedValue = _prefs.getString(key);

  // Check if the value is a JSON string
  if (storedValue != null) {
    try {
      return jsonDecode(storedValue); // Decode JSON String to Map or List
    } catch (e) {
      return storedValue; // Return as string if not JSON
    }
  }

  // Return other types directly
  return _prefs.get(key);
}