deleteUser method

Future<void> deleteUser()

DeleteUser - Valid for any authentication. This method deletes the current user from Firebase Authentication. It handles FirebaseAuthException to provide custom error messages. @throws String if the deletion fails due to an authentication error.

Implementation

Future<void> deleteUser() async {
  try {
    await _auth.currentUser?.delete();
    Get.offAll(() => const WelcomeScreen());
  } on FirebaseAuthException catch (e) {
    throw e.message!;
  } on FormatException catch (e) {
    throw e.message;
  } catch (e) {
    throw 'Unable to delete user. Try again.';
  }
}