Home > Software engineering >  How to save specific field value from Firestore to Flutter
How to save specific field value from Firestore to Flutter

Time:08-27

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.

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. Because my goal is to display Players that play in that club. And every game its another club.

CodePudding user response:

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.

CodePudding user response:

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.

  • Related