Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I cannot access the data when extracting data from firebase in Flutter

My code is written like this, but I cannot access the data in the output I get?

 void getMessages() async {
    final messages = await _firestore.collection('mesajlar').get();
    for (var message in messages.docs) {
      print(message.data);
    }
  }

enter image description here

like image 295
VolkanUstekidag Avatar asked Jun 16 '26 06:06

VolkanUstekidag


1 Answers

The problem is that you are calling data as a property when it is actually a function, you can see that in the documentation for DocumentSnapshot, which QueryDocumentSnapshot implements. So all you have to change is the print:

print(message.data());
like image 148
Ralemos Avatar answered Jun 18 '26 23:06

Ralemos