执行Firebase身份验证时无法处理Flutter中的PlatformException

时间:2020-10-12 09:01:49

标签: flutter dart

我正在使用Firebase signInWithEmail,它的性能很好,但是当我放置相同的电子邮件时,它抛出Platfrom异常“电子邮件已被另一个帐户使用”。对我来说这一切都很好,但是问题是我无法通过try / catch处理异常,因为它在messaage_codecs.dart中显示出来了

in this image app is just hang and this shows in message_codecs.dart I dont know why flutter is doing with me this... kindly #Team_flutter_fixit

press: () async {
                    try {
                      if (_formKey.currentState.validate()) {
                        if (CommonUsed.validlogin == true &&
                            CommonUsed.isValidk == true) {
                          var newUser =
                              await _auth.createUserWithEmailAndPassword(
                                  email: emailController.text.toString(),
                                  password: passwordController.text.toString());

                          if (newUser != null) {
                            Navigator.push(context,
                                MaterialPageRoute(builder: (context) {
                              return MainPage();
                            }));
                          } else {
                            CommonUsed.showFloatingFlushbar(
                                context, "Email already exist!");
                          }
                        }
                      }
                    } on PlatformException catch (e) {
                      // print(e.message.toString() + "?????????");
                      if (e.toString().contains(
                          'The email address is already in use by another account.')) {
                        print("EMAIL ADDRESS ALREADY IN USE");
                      }
                    } catch (e) {}
                  },

为什么为什么在稳定版本中会发生这种事情呢?或者,即使我的try catch在上面的代码中无法正常工作,我也该如何在try catch中处理呢????

0 个答案:

没有答案