Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.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 从CloudFireStore中检索一个用户的文档,并将其推送到Widget Flatter中_Firebase_Flutter_Dart_Google Cloud Firestore_Firebase Authentication - Fatal编程技术网

Firebase 从CloudFireStore中检索一个用户的文档,并将其推送到Widget Flatter中

Firebase 从CloudFireStore中检索一个用户的文档,并将其推送到Widget Flatter中,firebase,flutter,dart,google-cloud-firestore,firebase-authentication,Firebase,Flutter,Dart,Google Cloud Firestore,Firebase Authentication,多亏了 我们已经构建了从我的云存储集合“user”中检索数据的代码 目前,正如您在小部件中所看到的,我们将通过一封特定的电子邮件来展示其用途。”info@text.it" 由于您使用的是Firebase身份验证,因此从那里获取电子邮件: Future<QuerySnapshot> getData() async { var firebaseUser = await FirebaseAuth.instance.currentUser(); return awai

多亏了

我们已经构建了从我的云存储集合“user”中检索数据的代码 目前,正如您在小部件中所看到的,我们将通过一封特定的电子邮件来展示其用途。”info@text.it"


由于您使用的是Firebase身份验证,因此从那里获取
电子邮件

  Future<QuerySnapshot> getData() async {
    var firebaseUser  =  await FirebaseAuth.instance.currentUser();
    return await Firestore.instance.collection("user").where("email", isEqualTo: firebaseUser.email).getDocuments();
  }
Future getData()异步{
var firebaseUser=等待FirebaseAuth.instance.currentUser();
return wait wait Firestore.instance.collection(“user”).where(“email”,isEqualTo:firebaseUser.email).getDocuments();
}

I添加了变量var firebaseUser;但是它返回:在构建FutureBuilder(dirty,state:_FutureBuilderState#ec13a)时抛出了以下NoSuchMethodError:在null上调用了getter“documents”。接收者:null尝试呼叫:documents打印(firebaseUser.email)给您提供了什么?我是否可以询问是否要在此处添加静态文本:text(snapshot.data.documents[index].data[“name”]),如何操作?例如:文本(“欢迎”[“姓名]);文本(“欢迎${snapshot.data.documents[index.data[“name”]}”);
  void createRecord() async {
    await databaseReference.collection("user")
        .add({
      'name': '$name',
      'email': '$email',
      'password': '$password',
      'food': '$food',
      'image': '$image',
    }).then((value){
    print(value.documentID);
    });

Widget mailField() {
    return Center(
      child: Padding(
        padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
        child: Container(
          width: 360,
          child: TextField(

            style: TextStyle(color: Colors.white),
            keyboardType: TextInputType.emailAddress,
            onChanged: (value) {
              email = value;
            },
            decoration: InputDecoration(
              icon: new Icon(
                Icons.mail,
                color: Colors.white,
              ),
              hintText: 'La tua email',
              focusColor: Colors.white,
              hintStyle: TextStyle(color: Colors.white),
              prefixStyle: TextStyle(color: Colors.white),
              labelText: 'La tua email',
              labelStyle: TextStyle(
                color: Colors.white,
              ),
              contentPadding:
                  EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
              border: OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.circular(10)),
              ),
              enabledBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.white, width: 1.0),
                borderRadius: BorderRadius.all(Radius.circular(5)),
              ),
              focusedBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.white, width: 1.0),
                borderRadius: BorderRadius.all(Radius.circular(5.0)),
              ),
            ),
          ),
        ),
      ),
    );
  }

Widget submitButton() {
    return Container(
      child: SizedBox(
        width: 220,
        height: 40,
        child: RaisedButton(
          elevation: 5,
          onPressed: () async {
            setState(() {
              showProgress = true;
              createRecord();
            });
            try {
              final newuser = await _auth.createUserWithEmailAndPassword(
                  email: email, password: password);
              if (newuser != null) {
                Navigator.push(context, PageTransition(
                  type: PageTransitionType.fade,
                  child: WelcomeScreen(),
                ));
                setState(() {
                  showProgress = false;
                });
              }
            } catch (e) {
              return Container(
                child: Text('Error'),
              );
            }
          },
          child: Text(
            'Registrati',
            style: TextStyle(color: Colors.black),
          ),
          color: Colors.white,
          shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(8),
              side: BorderSide(color: Colors.black12, width: 1)),
        ),
      ),
    );
  }


  Future<QuerySnapshot> getData() async {
    var firebaseUser  =  await FirebaseAuth.instance.currentUser();
    return await Firestore.instance.collection("user").where("email", isEqualTo: firebaseUser.email).getDocuments();
  }