lab-64 / split-the-bill-client

Flutter App for easy and fast splitting up of receipts
4 stars 0 forks source link

#55 added logout button #61

Closed Morvvvv closed 3 months ago

Morvvvv commented 3 months ago

Placement of the button in the profile page can be changed. I do not think though, that it belongs into any other screen, as this functionaility would not be used often.

Throwing a UnauthenticatedException results in the wanted behavior, but not sure if this is how we want to keep it.

Closes #55

GR0ZA commented 3 months ago

tbh I don't see the point of a IsLogout flag. We also shouldn't throw an exception in case the behavior is wanted :smile:

I would rather:

Something like this:

  Future<void> logout() async {
    state = const AsyncLoading();
    await _authRepository.logout();

    if (!state.hasError) {
      state = const AsyncData(
          User(id: "", email: "", username: "", profileImgPath: ""));
    }
  }
GR0ZA commented 3 months ago

You also might like to add ref.listen(authStateProvider, (_, next) => next.showSnackBarOnError(context)); to the build method in profile_screen to show any errors that may appear on logout.

Morvvvv commented 3 months ago

Did it like you suggested and it works perfectly fine :)