signOut method

Future<AuthResponse<T>> signOut({
  1. Object? args,
  2. String? id,
  3. bool notifiable = true,
})
inherited

Implementation

Future<AuthResponse<T>> signOut({
  Object? args,
  String? id,
  bool notifiable = true,
}) async {
  try {
    emit(
      AuthResponse.loading(AuthType.logout),
      args: args,
      id: id,
      notifiable: notifiable,
    );

    final response = await delegate.signOut();
    if (!response.isSuccessful) {
      return _failure(
        response.error,
        type: AuthType.logout,
        args: args,
        id: id,
        notifiable: notifiable,
      );
    }

    _backupEmitEnabled = false;
    try {
      await _clearLocal();
    } finally {
      _backupEmitEnabled = true;
    }

    return emit(
      AuthResponse.unauthenticated(
        msg: msg.signOut.done,
        type: AuthType.logout,
      ),
      args: args,
      id: id,
      notifiable: notifiable,
    );
  } catch (error) {
    _backupEmitEnabled = true;
    return _failure(
      msg.signOut.failure ?? error.toString(),
      type: AuthType.logout,
      args: args,
      id: id,
      notifiable: notifiable,
    );
  }
}