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 颤振火基需要一份文件_Firebase_Flutter_Dart_Google Cloud Firestore - Fatal编程技术网

Firebase 颤振火基需要一份文件

Firebase 颤振火基需要一份文件,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,我在firestore中有一个登录页和一个集合,我可以在其中保存用户的一些信息,例如,他是否通过了登机屏幕。下次我打开应用程序时,我想检查用户是否通过了入职考试。如果他们这样做了:我重定向到另一个屏幕;如果没有,则重定向到入职 所有的例子都是阅读一个集合并获取所有文档,但是我只需要阅读一个我知道documentid的文档 我曾试图获得这样的数据,但没有成功 class LandingPage extends StatelessWidget { // LandingPage({@require

我在firestore中有一个登录页和一个集合,我可以在其中保存用户的一些信息,例如,他是否通过了登机屏幕。下次我打开应用程序时,我想检查用户是否通过了入职考试。如果他们这样做了:我重定向到另一个屏幕;如果没有,则重定向到入职

所有的例子都是阅读一个集合并获取所有文档,但是我只需要阅读一个我知道documentid的文档

我曾试图获得这样的数据,但没有成功

class LandingPage extends StatelessWidget {
  // LandingPage({@required this.auth});
  // final AuthBase auth;
     @override
      Widget build(BuildContext context) {
        final auth = Provider.of<AuthBase>(context, listen: false);
        return StreamBuilder<User>(
          stream: auth.onAuthStateChanged,
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.active) {
              User user = snapshot.data;
                  if (user == null) {
                return ChooseLanguage(
                    //     auth: auth,
                    );
              }

    // he i need to do a call to a ducment in the firestore
    //if the retuen is true then i go to page 1 else go to page 2

            } else {
              return Scaffold(
                body: Center(child: CircularProgressIndicator()),
              );
            }
          },
        );
      }
    }

我是否必须这样做-iama颤振初学者要获得一份文档,请执行以下操作:

getData()async{
await Firestore.instance.collection("users").document(id).get().then((value){
      print(value.data['name']);
    });
} 
您需要使用正确的集合名称value.data将包含您可以使用[]运算符访问的文档的数据

根据您的编辑,您正在检查checkonboarding是否为null,但由于它返回一个future,您需要使用wait:

    void sendData()async{
        bool value = await checkonBoarding(user);
      if (value != null) {
            return Provider<Database>(
              create: (_) => new FireStoreDatabase(uid: user.uid),
              child: Dashboard(usr: user, auth: auth),
            );
          } else {
            return Provider<Database>(
              create: (_) => new FireStoreDatabase(uid: user.uid),
              child: Onboarding(usr: user, auth: auth),
            );
          }
       }

bool checkonBoardingUser user{bool x=false;Firestore.instance.collectionusers.documentuser.uid.get.thenvalue{if value.data['onboarding']{user.onBoardingValue=value.data['onBoardingValue'];x=true;}否则{x=false;};返回x;}这是我使用的代码,它达到了。然后是值{'返回x的jumbs,我确定有os数据我想把代码放在一个返回bool的函数中,但是如果checkonBoardinguser==true,它就不起作用了。它给我的是:相等运算符==调用,引用的是不相关的类型。但是这个问题是什么?我怎么解决它呢?如果你知道如果你使用的是异步的,那么它将返回一个未来,所以你应该做getData.thenval{if!val{…};@peter我已经编辑了问题将完整的代码你能检查一下吗