Untitled

 avatar
faisalsalameh
dart
a year ago
1.5 kB
2
Indexable
Never
Future<void> outUser() async {
    // await api.logout();
    await box.delete(
      PersistenceKeys.accessToken,
    );
    await box.delete(
      PersistenceKeys.refreshToken,
    );
    await box.delete(
      PersistenceKeys.expireAccessToken,
    );
    await box.delete(
      PersistenceKeys.expireRefreshToken,
    );
    if (appUser.state.type == appConfig.authProviderType!.hUAWEI) {
      huaweiSiginService.signOut();
    }
    if (appUser.state.type == appConfig.authProviderType!.gOOGLE) {
      googleSignInService.signOut();
    }
    appUser.state = AppUser(user: UserData(), type: '', tokens: Tokens());
    await navigator.toAndRemoveUntil(Routes.splash);
  }

  void LogOut() async {
    navigator.back();
    showLoading();
    bool result = await api.logout();
    if (result) {
      await box.delete(
        PersistenceKeys.accessToken,
      );
      await box.delete(
        PersistenceKeys.refreshToken,
      );
      await box.delete(
        PersistenceKeys.expireAccessToken,
      );
      await box.delete(
        PersistenceKeys.expireRefreshToken,
      );
      if (appUser.state.type == appConfig.authProviderType!.hUAWEI) {
        huaweiSiginService.signOut();
      }
      if (appUser.state.type == appConfig.authProviderType!.gOOGLE) {
        googleSignInService.signOut();
      }
      navigator.back();
      appUser.state = AppUser(user: UserData(), type: '', tokens: Tokens());
      await navigator.toAndRemoveUntil(Routes.welcome);
    }
  }