getCachedUser method

  1. @override
Future<UserModel?> getCachedUser()
override

Implementation

@override
Future<UserModel?> getCachedUser() async {
  try {
    final userJson = _prefs.getString(_userKey);
    if (userJson != null) {
      final userMap = jsonDecode(userJson) as Map<String, dynamic>;
      return UserModel.fromJson(userMap);
    }
    return null;
  } catch (e) {
    throw const CacheException('Failed to get cached user data');
  }
}