Could someone please explain to me what is wrong with the following code.
The line .then((result) {window.alert("Record = ${oDbRec}");}) displays the following :
Record = Instance of ‘_ThenFuture@0x2900bd4a’
What I want is the result from the getObject(). The code:
fHtmDisplayOneClient(String sKey) {
var oDbRec;
oDbRec = fDbSelectOneClient(sKey)
.then((result) {window.alert("Record = ${oDbRec}");})
..catchError((oError) {window.alert("Error from fDbSelectOneClient. ${oError}");
});
}
Future fDbSelectOneClient(String sKey) {
var completer = new Completer();
idb.Transaction oDbTxn = ogDb1.transaction(sgTblClient, 'readwrite');
idb.ObjectStore oDbTable = oDbTxn.objectStore(sgTblClient);
idb.Request oDbReqGet = oDbTable.getObject(sKey);
oDbReqGet.onSuccess.first.then((val) => completer.complete(oDbReqGet.result));
oDbReqGet.onError.first.then((err) => completer.completeError(err));
return completer.future; // return the future
}
I think you want what the future returns, which is the ‘result’ object passed to .then()