English 中文(简体)
如何从收集的具体领域收集数据(Firebase Flutter)
原标题:How to fetch data from specific field in collections (Firebase Flutter)

我想从实地“干 to”中抽取价值,以便在我的法典中作出必要调整。

消防基地收集/外地/地点

“entergraph

我的《法典》希望改进我的《宪法》

import  package:cloud_firestore/cloud_firestore.dart ;
import  package:flutter/material.dart ;
import  package:inventory_app/screens/purchases/overview-purchases-syna.dart ;
import  package:inventory_app/screens/purchases/overview-purchases-syno.dart ;

class Divided1 extends StatefulWidget {
  const Divided1({super.key});

  @override
  State<Divided1> createState() => _Divided1State();
}

class _Divided1State extends State<Divided1> {
  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
        stream: FirebaseFirestore.instance
            .collection("pr_details")
            .where("dropdwoncompany")
            .snapshots(),
        builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
          if (snapshot.data == "ซินเนติก") {
            return OverviewPurchase();
          } else {
            return OverviewPurchase1();
          }
        });
  }
}

总的来说,你可以看到:if(snapshot.data ==“ซินเนติก”,因此,我想写一下,如果“dropdowncompany”=“ซินเนติก”---'>和职能Overview Purchase()正在运行,但如果它不等于“ซินเนติก”,它将履行其他职能,即

问题回答

The .where("dropdwoncompany") in your query is meaningless (and misspelled so that it doesn t match the field name in your document), so you should remove it.

相反,请在您的建筑商中从该文件中删除

builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
  if (snapshot.hasError) return Text( ERROR: ${snapshot.error} );
  if (!snapshot.hasData) return const CircularProgressIndicator();
  var data = snapshot.data!
  var docs = data.docs;

  if (docs[0].get("dropdowncompany") == "ซินเนติก") {
    return OverviewPurchase();
  } else {
    return OverviewPurchase1();
  }
});

如果做这项工作,则通过debugger 。 因此,每个线上都有一个分点,由小差错操作,并检查每个线上每个变量的价值,看看它是否与你预期的相匹配。





相关问题
Flutter App cannot be installed on Android TV

I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...

Moving the icon button to the right causes rendering issues

I am trying to align the icon button to the right of the Text field, I tried the row which made the icon button not centered vertically and now I am trying out the Stack widget. Here is my code - ...