开发者

Flutter - Navigator.push and pop isn't working with CircularProgressIndicator

开发者 https://www.devze.com 2022-12-07 21:19 出处:网络
The navigator.push does not redirect me to the page that I do want to be redirected as well as the navigator.pop doesn\'t pop the circularprogressindicator and I am stuck there.

The navigator.push does not redirect me to the page that I do want to be redirected as well as the navigator.pop doesn't pop the circularprogressindicator and I am stuck there.

Here are the imports of my the file.

import 'package:file_name/products/widget_helper/register_ui_widget_functions.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../helper/user_registration_helper.dart';
import '../model/user_registration_model.dart';
import '../pages/home_page.dart';

register_widgets.dart

Future signUpUser(emailUserCtrlr, passwordUserCtrlr, repeatPasswordUserCtrlr,
    firstNameUserCtrlr, lastNameUserCtrlr, context) async {
  RegistrationUser.checkFieldValidation(emailUserCtrlr, passwordUserCtrlr,
      repeatPasswordUserCtrlr, firstNameUserCtrlr, lastNameUserCtrlr);
  RegistrationUser.confirmPassword(
      passwordUserCtrlr, repeatPasswordUserCtrlr);
  if (RegistrationUser.confirmPassword(
      passwordUserCtrlr, repeatPasswordUserCtrlr)) {
        // CricularProgressIndicator here...
    Reusable开发者_StackOverflow社区Widgets.showDialogCircularIndicator(context);
    try {
      await FirebaseAuth.instance.createUserWithEmailAndPassword(
          email: emailUserCtrlr.text.trim(),
          password: passwordUserCtrlr.text.trim());
      FirestoreUserHelper.create(UserModel(
        firstName: firstNameUserCtrlr.text.trim(),
        lastName: lastNameUserCtrlr.text.trim(),
        userEmail: emailUserCtrlr.text.trim(),
      ));
      ToastRegisterUser.registeredSuccessfully();
      // Navigator.push not working
      Navigator.push(
        context,
        MaterialPageRoute(builder: (context) => const UserHomePage()),
      );
    } on FirebaseAuthException catch (e) {
      ToastRegisterUser.emailAlreadyRegistered(emailUserCtrlr);
    }
    // Navigator Pop not working
    Navigator.of(context).pop();
  }
}

Here is my CircularProgressIndicator, I put it on a function so that It could be reusable.

static showDialogCircularIndicator(BuildContext context) {
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return const Center(
            child: CircularProgressIndicator(),
          );
        });
  }

I have tried, removing it as a function and adding the imports by redoing it. However it couldn't still get fixed. I do not know if this is a firebase problem or just the Flutter UI.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号