Flutter未向Firebase插入新用户



在我的Flutter项目中,我试图通过电子邮件注册新用户密码和

在firebase控制台中通过电子邮件启用Auth密码和但是新用户没有插入

来自Cloud Firestore的其他数据获取成功的

调试控制台消息:当我填写完邮件后点击注册按钮并通过 I/BiChannelGoogleApi( 7328): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzao@b8e2d46之后什么也没发生:

在我的

pubspec.yaml

firebase_auth: ^ 0.18.3

firebase_core: ^ 0.5.2

下面是我的代码:

signInSheet(BuildContext context) {
return showModalBottomSheet(
context: context,
builder: (context) {
return new Container(
height: 400.0,
width: 400.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
color: Color(0xFF191531)),
child: Center(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
decoration: InputDecoration(
hintText: 'Enter email...',
hintStyle: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
)),
controller: emailController,
style: TextStyle(color: Colors.white),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
obscureText: true,
decoration: InputDecoration(
hintText: 'Enter password...',
hintStyle: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
)),
controller: passwordController,
style: TextStyle(color: Colors.white),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FloatingActionButton(
backgroundColor: Colors.redAccent,
child:
Icon(FontAwesomeIcons.check, color: Colors.white),
onPressed: () =>
Provider.of<Authentication>(context, listen: false)
.createNewAccount(emailController.text,
passwordController.text)
.whenComplete(() {
if (Provider.of<Authentication>(context,
listen: false)
.getErrorMessage !=
null) {
Navigator.pushReplacement(
context,
PageTransition(
child: HomeScreen(),
type: PageTransitionType.leftToRight));
} else {
Navigator.pushReplacement(
context,
PageTransition(
child: Login(),
type: PageTransitionType.leftToRight));
}
})),
),
Text(
Provider.of<Authentication>(context, listen: true)
.getErrorMessage,
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
)
],
),
),
);
});
}
}

不知道这是什么

Provider.of<Authentication>(context, listen: false)
.createNewAccount(emailController.text,
passwordController.text)

无论如何,你需要的是当创建用户的电子邮件和密码是成功的,你需要添加条目到firestore

//id obtained from current user instance
User user = FirebaseAuth.instance.currentUser;
FirebaseFirestore.instance.collection("users").doc(user.id).set(
{"username": "username, "phoneNo": "phone", "desc": "null","id":user.id});

相关内容

最新更新