I can't seem to pass a QuerySnapshot from one class to another without losing the Snapshot so I am trying to find a work around (see my post here). I am trying to pull the data again by using a StreamBuilder.
StreamBuilder (
stream: _db.collection('agency').doc(globals.agencyId).
collection('trxns').doc(globals.currentTrxnId).snapshots(),
builder: (context, trxnSnapshot) { <<<< ERROR 1
if (trxnSnapshot.hasData) {
var outPut = trxnSnapshot.data(); <<<< ERROR 2
clientFNameController.text = trxnSnapshot.data.data['clientFName'] ?? ""; <<<< ERROR 3
}
)
I am getting some errors.
The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type. I have tried adding "?" and "!" but it is not working.
Found this line of code in a post but I am not sure how to get the data from the snapshot.
This error will be fixed after #2 is fixed.
These should be easy fixes but I'm not sure how to do it.
EDIT I tried adding type casting as shown below but I get new errors.
StreamBuilder<QuerySnapshot> (
stream: _db.collection('agency').doc(globals.agencyId).
collection('trxns').doc(globals.currentTrxnId).snapshots(),
builder: (context, trxnSnapshot) {
if (trxnSnapshot.hasData) {
var outPut = (trxnSnapshot.data() as QueryDocumentSnapshot);
clientFNameController.text = trxnSnapshot.data.data['clientFName'] ?? "";
}
)