简体   繁体   English

如何将特定字段值从 Firestore 保存到 Flutter

[英]How to save specific field value from Firestore to Flutter

So my problem is that I know how to write in Firebase, update it, and read data... but now I need to get a specific field from a document and save it in some variable or string, and I am stuck there.所以我的问题是我知道如何在 Firebase 中写入,更新它并读取数据......但是现在我需要从文档中获取特定字段并将其保存在某个变量或字符串中,而我被困在那里。

Picture of what I need我需要的图片

Here is a field I need to get.这是我需要得到的一个字段。

Here is where I need to save it这是我需要保存的地方

So I need it to be saved so I can use it in code, specifically as an isEqual value.所以我需要保存它,以便我可以在代码中使用它,特别是作为 isEqual 值。 Because my goal is to display Players that play in that club.因为我的目标是展示在那个俱乐部踢球的球员。 And every game its another club.每场比赛都是另一个俱乐部。

firstly you have link you app with firebase then you need to import 3 plugin firebase core plugin firebase Firestore and cloud firebase then you need to in your Main.dart here first you create a Class Then you control it by TextController then you'll post you data After the data will successfully post on firebase then you will get response from firebase.. Actually I'll work on Firebase you can say rule Put Get Update Delete & fetch in other word these are the Queries. firstly you have link you app with firebase then you need to import 3 plugin firebase core plugin firebase Firestore and cloud firebase then you need to in your Main.dart here first you create a Class Then you control it by TextController then you'll post you数据在数据将成功发布到 firebase 之后,您将收到 firebase 的响应。实际上我将在 Firebase 上工作,您可以说规则 Puteries 删除其他字词。

I found solution:我找到了解决方案:

String? valueFromFirebase;
  Future<String?> getData() async{
    var a = await clubData.doc('Home').get();
    setState(() {
      valueFromFirebase= a['homeClubName'];
    });
  }

So when I need value from field ( in my case homeClubName) I just call string valueFromFirebase where I need it.因此,当我需要来自字段的值(在我的情况下为 homeClubName)时,我只需在需要它的地方调用字符串 valueFromFirebase。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将来自 Firestore 的字段值存储在 Flutter 中? - How to store field value from firestore in Flutter? 如何从列表中分别获取字段名称和字段值<object?>从 Firestore flutter</object?> - How To Get Field Name And Field Value Separately From List<Object?> From Firestore flutter 如何更新 Firestore 文档中特定字段的值? - How to update value of a specific field in Firestore document? 从 Firestore Flutter 保存数据 - Save data from Firestore Flutter 如何从 Firestore flutter 的参考字段中获取值并在 stream 构建器中显示? - How to get value from reference field in firestore flutter and display in stream builder? 我如何从 flutter firestore 中的 querysnapshot 获取单个字段值 - How do i get the single field value from querysnapshot in flutter firestore 如何使用特定参数 flutter 从 Firestore 中删除数据? - How to delete data from Firestore with specific parameter flutter? 如何使用 flutter 和 dart 从 Cloud Firestore 检索特定数据? - how to retrieve specific data from Cloud Firestore using flutter and dart? Flutter - Firestore - 列出来自集合字段的字符串,并在按下“保存设置”后更新 Fire Store - Flutter - Firestore - List String to be from collection field and update fire store once "Save Setting' is pressed 如何通过文档 ID 从 firestore 网站获取特定字段数据 - How get specific Field data by document id from firestore website
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM