Prior to the update, document['field'] would result in null if it did not exist. Now it throws a Bad State error. The null response is needed because the field does not exist in some historical data and/or optional data in the Firebase collection. Confirmed this in the following report as well:
https://github.com/FirebaseExtended/flutterfire/issues/3826
Is there a way to capture the error and ignore it or set it to null or empty string?
static Pool dataFromDocument(QueryDocumentSnapshot document) {
return Pool()
..authUID = document.get('authUID')
..documentID = document.id
..propertyManagerID = document['propertyManagerID'] as String
}
static Stream<QuerySnapshot> getData(String authUID) {
CollectionReference poolRef = FirebaseFirestore.instance.collection(dataDB);
Query query = poolRef.where('authUID', isEqualTo: authUID.trim());
return query.snapshots();
}