从Firebase提取数据到Flutter应用程序时出错。

huangapple go评论68阅读模式
英文:

Error when extracting data from firebase into flutter app

问题

以下是您要翻译的内容:

I want to ask for some help or advice.
I have a simple form which stores data in Firebase.
I created a new page where I want to display that information. I am using StreamBuilder to display the data for the logged user.

return Scaffold(
  appBar: AppBar(
    title: const Text("Your upcoming appointments"),
  ),
  body: SafeArea(
    child: Column(
      children: [
        StreamBuilder(
          stream: FirebaseFirestore.instance.collection('client_bookings_doc').where('email', isEqualTo: currentUser.currentUser!.email).snapshots(),
          builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
            if (snapshot.hasData) {
              return ListView.builder(
                itemCount: snapshot.data!.docs.length,
                shrinkWrap: true,
                itemBuilder: (context, i) {
                  var data = snapshot.data!.docs[i];
                  print(data['email']);
                  return Text(data['email']);
                },
              );
            } else {
              return const Text("error");
            }
          },
        ),
      ],
    ),
  ),
);

I don't understand why I am getting that error:

W/GooglePlayServicesUtil(3777): .................. requires the Google Play Store, but it is missing.
E/GooglePlayServicesUtil(3777): GooglePlayServices not available due to error 9
W/Firestore(3777): (24.4.2) [GrpcCallProvider]: Failed to update ssl context: com.google.android.gms.common.GooglePlayServicesNotAvailableException

I was following a few tutorials online and they both work fine.
Any help will be appreciated.


Update: I changed the device to google pixel 2 and now the error is

W/ProviderInstaller(5334): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]

从Firebase提取数据到Flutter应用程序时出错。

英文:

I want to ask for some help or advice.
I have a simple form which stores data in Firebase.
I created a new page where I want to display that information. I am using StreamBuilder to display the data for the logged user.

return Scaffold(
  appBar: AppBar(
    title: const Text(&quot;Your upcoming appointments&quot;),
  ),
  body: SafeArea(
    child: Column(
      children: [
        StreamBuilder(
          stream: FirebaseFirestore.instance.collection(&#39;client_bookings_doc&#39;).where(&#39;email&#39;, isEqualTo: currentUser.currentUser!.email).snapshots(),
          builder: (context, AsyncSnapshot&lt;QuerySnapshot&gt; snapshot) {
            if (snapshot.hasData) {
              return ListView.builder(
                itemCount: snapshot.data!.docs.length,
                shrinkWrap: true,
                itemBuilder: (context, i) {
                  var data = snapshot.data!.docs[i];
                  print(data[&#39;email&#39;]);
                  return Text(data[&#39;email&#39;]);
                },
              );
            } else {
              return const Text(&quot;error&quot;);
            }
          },
        ),
      ],
    ),
  ),
);

I don't understand why I am getting that error:

> W/GooglePlayServicesUtil( 3777): .................. requires the Google Play Store, but it is missing.
E/GooglePlayServicesUtil( 3777): GooglePlayServices not available due to error 9
W/Firestore( 3777): (24.4.2) [GrpcCallProvider]: Failed to update ssl context: com.google.android.gms.common.GooglePlayServicesNotAvailableException

I was following a few tutorials online and they both work fine.
Any help will be appreciated.


Update: I changed the device to google pixel 2 and now the error is

> W/ProviderInstaller( 5334): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]

从Firebase提取数据到Flutter应用程序时出错。

答案1

得分: 1

这个查询与你的截图中的文档结构不匹配:

FirebaseFirestore.instance
  .collection('client_bookings_doc')
  .where('email', isEqualTo: currentUser.currentUser!.email)
  .snapshots()

在你的截图中没有名为 client_bookings_doccollection。相反,有一个根集合 client_bookings,其中包含一个名为 client_bookings_docdocument,然后又有一个名为 client_bookings 的子集合。

如果你想跨所有 client_bookings 集合进行查询,你可以使用集合组查询

FirebaseFirestore.instance
  .collectionGroup('client_bookings') // &#128072;
  .where('email', isEqualTo: currentUser.currentUser!.email)
  .snapshots()
英文:

This query doesn't match the document structure in your screenshot:

FirebaseFirestore.instance
  .collection(&#39;client_bookings_doc&#39;)
  .where(&#39;email&#39;, isEqualTo: currentUser.currentUser!.email)
  .snapshots()

There is no collection client_bookings_doc in your screenshot. Instead there is a root collection client_bookings with a document client_bookings_doc and then a subcollection again named client_bookings.

If you want to query across all client_bookings collection, you can use a collection group query:

FirebaseFirestore.instance
  .collectionGroup(&#39;client_bookings&#39;) // &#128072;
  .where(&#39;email&#39;, isEqualTo: currentUser.currentUser!.email)
  .snapshots()

huangapple
  • 本文由 发表于 2023年2月19日 18:32:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499490.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定