'Class '_JsonDocumentSnapshot' has no instance method 'call'. Receiver: Instance of '_JsonDocumentSnapshot' Tried calling: call()

I trying to retrieving the data in Firebase with StreamBuilder but it appear this error. Does anyone know how to solve this? Appreciate so much for the help.

This is my code:

Container(
                child: StreamBuilder(
              stream: FirebaseFirestore.instance
                  .collection('orderInfo')
                  .doc(user.uid + 'order')
                  .snapshots(),
              builder: (context, snapshot) {
                if (!snapshot.hasData) {
                  return Text('No data');
                } else {
                  Map<String, dynamic> doc =
                      snapshot.data() as Map<String, dynamic>;
                  return Text(doc['clLady']);
                }
              },
            ))

This is my firebase storage: enter image description here

I want to retrieve the clID but somehow it does not work.

This is the error message.

enter image description here

Thank you so much!!!



Solution 1:[1]

Drop the parenthesis at the end of data like this

               Map<String, dynamic> doc =
                      snapshot.data as Map<String, dynamic>;

snapshot.data is an attribute not a method or callable class, thats why you are getting an error.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1