如何使用 sendEmailVerification() 方法

Eff*_*fie 6 dart firebase firebase-authentication flutter

尝试在 Flutter 中为 Firebase 电子邮件/密码身份验证方法设置firebase_auth包,但需要电子邮件验证方面的帮助。

我遇到了sendEmailVerification(); firebase_auth 包提供的方法,但需要一些关于设置的建议。有没有人有一个工作代码示例可以遵循?

// From firebase_auth package docs > https://pub.dartlang.org/documentation/firebase_auth/latest/firebase_auth/FirebaseUser/sendEmailVerification.html

Future<void> sendEmailVerification() async {
  // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
  // https://github.com/flutter/flutter/issues/26431
  // ignore: strong_mode_implicit_dynamic_method
  await FirebaseAuth.channel.invokeMethod(
      'sendEmailVerification', <String, String>{'app': _app.name});
}
Run Code Online (Sandbox Code Playgroud)

如果可能的话,任何有关正确设置的帮助、建议、指导以及要遵循的工作示例代码将不胜感激。

R. *_*gan 11

如果您制作FirebaseUser. 它可以像这样使用:

await _auth.createUserWithEmailAndPassword (
  email: //wherever you set their email,
  password: //wherever you set their password,
).then((FirebaseUser user) {
  //If a user is successfully created with an appropriate email
if (user != null){
  user.sendEmailVerification();
}
})
.catchError();
Run Code Online (Sandbox Code Playgroud)