switchSession method

Future<AuthSession?> switchSession(
  1. AuthSession? session
)

Switch to a different session

Implementation

Future<AuthSession?> switchSession(AuthSession? session) async {
  _currentSession = session;
  _sessionController.add(_currentSession);

  final prefs = await SharedPreferences.getInstance();

  if (session != null) {
    await prefs.setString(lastSessionId, session.id);
  } else {
    await prefs.remove(lastSessionId);
  }
  return _currentSession;
}