I have an int named "length" in my code and I am trying to change it's value from a field in my Cloud Firestore:
int length;
_handlePressed(context) {
DocumentReference postReference = Firestore.instance.collection(ISBN).document(post);
postReference.get().then((datasnapshot){
if(datasnapshot.exists) {
length = datasnapshot.data["length"];
print(length.toString());
}
});
}
The field "length" is stored as a Number Type in my Firestore.
The problem is that the print operation does not execute and printing length elsewhere shows null in the console. What am i missing?