getCachedUser method

Future<UserModel?> getCachedUser()

The UserModel currently persisted in SecureStorage, or null if none exists.

Does not contact the network. Used as a fallback when the API is unreachable during startup.

Implementation

Future<UserModel?> getCachedUser() async {
  _logger.info('[UserRepository] Reading cached user from secure storage');
  final UserModel? user = await _secureStorage.getUserModel();

  if (user == null) {
    _logger.warn('[UserRepository] No cached user found in secure storage');
  } else {
    _logger.info(
      '[UserRepository] Cached user loaded: '
      '${user.firstName} ${user.lastName}',
    );
    _setSentryUser(user);
  }

  return user;
}