signOut method

Future<void> signOut()

Signs out the current user and clears user-scoped local state.

Implementation

Future<void> signOut() async {
  state = const AsyncLoading();

  state = await AsyncValue.guard(() async {
    final userId = ref.read(currentUserProvider)?.id;
    if (userId != null) await deleteUserData(ref, userId);
    await ref.read(notificationServiceProvider).deleteCurrentInstallation();
    await ref.read(authServiceProvider).signOut();
  });
}