运行getDocuments(source: Source.server)
时出现此错误。我不确定错误所指向的是什么,或者Future<null>?
是什么。
cloud_firestore:0.12.10 + 2
E/flutter (12116): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'Future<dynamic>' is not a subtype of type 'Future<Null>?'
E/flutter (12116): #0 _FutureListener.handleError (dart:async/future_impl.dart:159:7)
E/flutter (12116): #1 Future._propagateToListeners.handleError (dart:async/future_impl.dart:694:47)
E/flutter (12116): #2 Future._propagateToListeners (dart:async/future_impl.dart:715:24)
E/flutter (12116): #3 Future._completeWithValue (dart:async/future_impl.dart:526:5)
E/flutter (12116): #4 Future.timeout.<anonymous closure> (dart:async/future_impl.dart:780:16)
E/flutter (12116): #5 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (12116): #6 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (12116): #7 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
E/flutter (12116): #8 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
E/flutter (12116): #9 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
E/flutter (12116): #10 Future._completeWithValue (dart:async/future_impl.dart:526:5)
E/flutter (12116): #11 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
E/flutter (12116): #12 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
E/flutter (12116): #13 Query.getDocuments (package:cloud_firestore/src/query.dart)
E/flutter (12116): <asynchronous suspension>
E/flutter (12116): #14 _OrderCardCheckableListState._retrieveInitialTenOrders (package:lightweight_pos/inventory_management_workflow/settlement_management/input_new_settlement_form/add_supplier_faktur_sub_route.dart:65:10)
E/flutter (12116): #15 _OrderCardCheckableListState.initState (package:lightweight_pos/inventory_management_workflow/settlement_management/input_new_settlement_form/add_supplier_faktur_sub_route.dart:143:5)
E/flutter (12116): #16 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4640:58)
E/flutter (12116): #17 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
E/flutter (12116): #18 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
E/flutter (12116): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18)
E/flutter (12116): #20 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
E/flutter (12116): #21 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
E/flutter (12116): #22 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4481:5)
E/flutter (12116): #23 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
E/flutter (12116): #24 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
E/flutter (12116): #25 Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18)
E/flutter (12116): #26 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
E/flutter (12116): #27 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
E/flutter (12116): #28 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4481:5)
E/flutter (12116): #29 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
E/flutter (12116): #30 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
E/flutter (12116): #31 Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18)
E/flutter (12116): #32 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
E/flutter (12116): #33 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
E/flutter (12116): #34 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4481:5)
E/flutter (12116): #35 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
E/flutter (12116): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
E/flutter (12116): #37 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5947:32)
E/flutter (12116): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
E/flutter (12116): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18)
E/flutter (12116): #40 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16)
E/flutter (12116): #41 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:11)
E/flutter (12116): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5)
E/flutter (12116): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4481:5)
E/flutter (12116): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4666:11)
E/flutter (12116): #45
await Firestore.instance
.collection('Suppliers')
.where('SupplierID',
isEqualTo: DataCenter.currentInputNewSettlementPageData.supplierID)
.limit(10)
.getDocuments(source: Source.server)
.timeout(MyApp.systemTimeout)
.then((QuerySnapshot snapshot) {
if (snapshot.documents == null || snapshot.documents.length == 0) noDocuments = true;
_lastDocument = snapshot.documents.last;
for (DocumentSnapshot doc in snapshot.documents) {
_listOfSettleFakturData.add({
'ReferenceNumber': doc['ReferenceNumber'],
'FakturNumber': doc['FakturNumber'],
'UnpaidAmount': doc['UnpaidAmount'],
'UploadTime': doc['UploadTime'],
'PaymentAmount': 1,
'NewUnpaidAmount': doc['UnpaidAmount']
});
}
答案 0 :(得分:0)
该错误似乎源于我试图访问文档中不存在的字段的事实。这是因为我尝试访问错误的集合。
供应商(每个文档的字段如下):
补给(我打算访问的集合,每个文档的字段如下):
据我了解,这就是问题所在,如果有人知道我错了,请纠正,我想知道正确的原因,以便下次可以避免。