Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重新登录时Firebase用户未保存到数据库_Firebase_Flutter_Google Cloud Firestore_Firebase Security - Fatal编程技术网

重新登录时Firebase用户未保存到数据库

重新登录时Firebase用户未保存到数据库,firebase,flutter,google-cloud-firestore,firebase-security,Firebase,Flutter,Google Cloud Firestore,Firebase Security,单击注册页面时,它不会导航到主页。而且数据库也不是自动创建的。尽管身份验证页面中出现了列表。注册正在进行中 //signuppage.dart onPressed: (){ var createUserWithEmailAndPassword = FirebaseAuth.instance.createUserWithEmailAndPassword( email: _email,

单击注册页面时,它不会导航到主页。而且数据库也不是自动创建的。尽管身份验证页面中出现了列表。注册正在进行中

//signuppage.dart

    onPressed: (){
                  var createUserWithEmailAndPassword = FirebaseAuth.instance.createUserWithEmailAndPassword(

                    email: _email,
                     password: _password);
                  createUserWithEmailAndPassword.then((signedInUser){


                      UserManagement().storeNewUser(signedInUser, context);


                     }).catchError((e){
                       print(e.toString());
                     });

                },
这是usermanagement.dart

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/widgets.dart';

class UserManagement {
    storeNewUser(user, context) {
    Firestore.instance.collection('/users').add({
      'email': user.email,
      'uid': user.uid
    }).then((value) {
    Navigator.of(context).pop();
    Navigator.of(context).pushReplacementNamed('/homepage');

   }).catchError((e) {
      print(e);
   });
   }
   }
当应用程序运行此错误提交时

   I/flutter ( 1507): NoSuchMethodError: Class 'AuthResult' has no instance getter 'email'.
   I/flutter ( 1507): Receiver: Instance of 'AuthResult'
   I/flutter ( 1507): Tried calling: email

面对此问题,无法将数据存储到firebase cloud

身份验证的结果是AuthResult,而不是firebase用户

要将用户传递给您的函数,您应该发送
signedUser.user
,而不仅仅是
signedUser

我建议您仔细阅读文档,因为这些事情很快就会变得棘手

我希望这对你有帮助

编辑:

我还建议设置您在函数中使用的变量类型,这样您的IDE在键入时就会指出错误

例如,你应该改变

storeNewUser(user, context)
进入

storeNewUser(FirebaseUser user, BuildContext context)