Closed Morvvvv closed 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:
logout()
function in AuthRepository
& RemoteAuthRepository
return void
instead of User
logout()
function in RemoteAuthRepository
return builder: (data) {}
instead of User.fromMap...
await _authRepository.logout()
in auth_state
without a guard!state.hasError
Something like this:
Future<void> logout() async {
state = const AsyncLoading();
await _authRepository.logout();
if (!state.hasError) {
state = const AsyncData(
User(id: "", email: "", username: "", profileImgPath: ""));
}
}
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.
Did it like you suggested and it works perfectly fine :)
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