Need flutter app execution to wait before going to next step

I have a process that I want to run in a specific order when registering a new user.

  1. The new user clicks on the Create Account link
  2. The new user is taken to the User Registration screen where they can enter name, email, and password
  3. The click on the Register button.
  4. They are taken to a subscription payment page where they click on the Subscribe Now link. This page is part of the Stripe payment kit.
  5. The Stripe payment screen is shown so they can enter in payment information and the user

This is in the backend
6. Payment is made using Stripe
7. The user is registered into the Firebase authentication
8. A verification email is sent to the user

However, between steps 4 and 5, the verification email is sent. I think this is because of the “await” statement on the Subcribe Now button.

How do I get the execution to wait until the payment method has completed?

Here is the code for the button:

  TextButton(
    child: const Text('Subscribe Now!'),
    onPressed: () async {
      await makePayment(); <<<< I WANT EXECUTION TO WAIT HERE

      /// Register the new user
      try {
        final newUser = await _auth.createUserWithEmailAndPassword(
            email: widget.email, password: widget.password);
        if (newUser != null) {
          ref
              .read(usersNotifierProvider.notifier)
              .updateuserID(newUser.user!.uid);

          ref
              .read(usersNotifierProvider.notifier)
              .updateEmail(newUser.user!.email!);
          ref
              .read(globalsNotifierProvider.notifier)
              .updatenewUser(true);
          ref
              .read(globalsNotifierProvider.notifier)
              .updatenewCompany(true);

          /// Send the email verification
          Navigator.of(context).pushReplacement(MaterialPageRoute(
              builder: (context) => const VerifyEmailScreen()));
        } else {
          setState(() {
            registrationFail = true;
          });
        }
        setState(() {
          showSpinner = false;
        });
      } on FirebaseAuthException catch (error) {
        switch (error.code) {
          case "ERROR_INVALID_EMAIL":
          case "invalid-email":
            errorMessage =
                "Your email address appears to be malformed.";
            break;
          case "email-already-in-use":
            errorMessage = "Email is already in use.";
            break;
          case "ERROR_WRONG_PASSWORD":
          case "wrong-password":
            errorMessage = "Your password is wrong.";
            break;
          case "weak-password":
            errorMessage = "Weak password";
            break;
          case "ERROR_USER_NOT_FOUND":
          case "user-not-found":
            errorMessage = "User with this email doesn't exist.";
            break;
          case "ERROR_USER_DISABLED":
          case "user-disabled":
            errorMessage =
                "User with this email has been disabled.";
            break;
          case "ERROR_TOO_MANY_REQUESTS":
          case "too-many-requests":
            errorMessage = "Too many requests. Try again later.";
            break;
          case "ERROR_OPERATION_NOT_ALLOWED":
          case "operation-not-allowed":
            errorMessage =
                "Signing in with Email and Password is not enabled.";
            break;
          default:
            errorMessage =
                "An undefined Error happened. Please try again.";
        }

        if (errorMessage != "") {
          ScaffoldMessenger.of(context).showSnackBar((SnackBar(
            content: Center(
              child: Text(
                errorMessage,
                style: const TextStyle(
                    color: Colors.black,
                    fontWeight: FontWeight.w900),
              ),
            ),
            behavior: SnackBarBehavior.floating,
            margin: EdgeInsets.only(
              bottom: MediaQuery.of(context).size.height - 100,
              left: 10,
              right: 10,
            ),
            backgroundColor: Colors.redAccent,
          )));
        }
      }
    }),

Thanks for your help!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật