该项目的Github:here
Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
Running Xcode build...
Xcode build done. 22.0s
Configuring the default Firebase app...
Configured the default Firebase app __FIRAPP_DEFAULT.
Waiting for iPhone SE (2nd generation) to report its views...
Debug service listening on ws://127.0.0.1:54630/tFUTjcfl640=/ws
Syncing files to device iPhone SE (2nd generation)...
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building StreamBuilder<CalendarDetailModel>(dirty, state:
flutter: _StreamBuilderBaseState<CalendarDetailModel, AsyncSnapshot<CalendarDetailModel>>#836df):
flutter: A build function returned null.
flutter: The offending widget is:
flutter: StreamBuilder<CalendarDetailModel>
flutter: Build functions must never return null.
flutter: To return an empty space that causes the building widget to fill available room, return
flutter: "Container()". To return an empty space that takes as little room as possible, return
flutter: "Container(width: 0.0, height: 0.0)".
flutter:
flutter: The relevant error-causing widget was:
flutter: StreamBuilder<CalendarDetailModel>
flutter: file:///Users/lethanhtu/Desktop/firebase_authentication/lib/ui/calendar_detail.dart:54:20
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:276:7)
flutter: #1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:297:4)
flutter: #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4516:7)
flutter: #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4684:11)
flutter: #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4227:5)
flutter: #5 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4490:5)
flutter: #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4675:11)
flutter: #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4485:5)
flutter: ... Normal element mounting (39 frames)
flutter: #46 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3455:14)
flutter: #47 Element.updateChild (package:flutter/src/widgets/framework.dart:3223:18)
flutter: #48 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1162:36)
flutter: #49 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1147:20)
flutter: #50 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2612:19)
flutter: #51 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1140:11)
flutter: #52 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:354:23)
flutter: #53 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1866:58)
flutter: #54 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:918:15)
flutter: #55 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1866:13)
flutter: #56 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:343:5)
flutter: #57 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:427:5)
flutter: #58 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:79:12)
flutter: #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #60 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:135:11)
flutter: #61 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:375:11)
flutter: #62 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #63 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:452:13)
flutter: #64 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1443:12)
flutter: #65 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1352:20)
flutter: #66 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #67 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #68 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #69 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #70 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #71 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #72 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #73 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #74 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #75 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #76 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #77 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #78 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #79 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #80 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #81 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #82 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #83 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:207:11)
flutter: #84 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #85 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:11)
flutter: #86 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:480:7)
flutter: #87 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7)
flutter: #88 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:399:14)
flutter: #89 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #90 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #91 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #92 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #93 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1267:11)
flutter: #94 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #95 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #96 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #97 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #98 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #99 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #100 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #101 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:556:15)
flutter: #102 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #103 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #104 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #105 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #106 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #107 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #108 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #109 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #110 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #111 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #112 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #113 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #114 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3219:13)
flutter: #115 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #116 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:700:15)
flutter: #117 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #118 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #119 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #120 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #121 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #122 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #123 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #124 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #125 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #126 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #127 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #128 RenderView.performLayout (package:flutter/src/rendering/view.dart:167:13)
flutter: #129 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1630:7)
flutter: #130 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
flutter: #131 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:402:19)
flutter: #132 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:865:13)
flutter: #133 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:284:5)
flutter: #134 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113:15)
flutter: #135 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1052:9)
flutter: #136 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:861:7)
flutter: (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
flutter:
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Status code is 200
[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, String>'
#0 new CalendarDetailModel (package:firebaseauthentication/models/calendar_detail_model.dart:26:40)
#1 CalendarDetailRepository.fetchRoom.<anonymous closure> (package:firebaseauthentication/resources/calendar_detail_repository.dart:38:23)
#2 List.forEach (dart:core-patch/growable_array.dart:289:8)
#3 CalendarDetailRepository.fetchRoom (package:firebaseauthentication/resources/calendar_detail_repository.dart:35:19)
<asynchronous suspension>
#4 CalendarDetailBloc.loadRoom (package:firebaseauthentication/blocs/calendar_detail_bloc.dart:16:36)
#5 CalendarDetailsState.initState (package:firebaseauthentication/ui/calendar_detail.dart:35:10)
#6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4649:58)
#7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4485:5)
#8 Element.inflateWidget (package:flutter/<…>
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building StreamBuilder<CalendarDetailModel>(dirty, state: _StreamBuilderBaseState<CalendarDetailModel, AsyncSnapshot<CalendarDetailModel>>#836df):
A build function returned null.
The offending widget is: StreamBuilder<CalendarDetailModel>
Build functions must never return null.
To return an empty space that causes the building widget to fill available room, return "Container()". To return an empty space that takes as little room as possible, return "Container(width: 0.0, height: 0.0)".
The relevant error-causing widget was:
StreamBuilder<CalendarDetailModel> file:///Users/lethanhtu/Desktop/firebase_authentication/lib/ui/calendar_detail.dart:54:20
When the exception was thrown, this was the stack:
#0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:276:7)
#1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:297:4)
#2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4516:7)
#3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4684:11)
#4 Element.rebuild (package:flutter/src/widgets/framework.dart:4227:5)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
答案 0 :(得分:3)
有关问题所在的错误非常清楚。在您StreamBuilder
中,您不肯返回任何东西。您有:
builder: (context, snapshot) {
if (snapshot.hasError) {
return CircularProgressIndicator();
} else if (snapshot.hasData) {
...
}
仅在出现错误或数据可用时返回某些内容。但是,并不总是有可用数据或错误,因此,当这两个条件都不成立时,您必须返回一些信息。
只需在这些return CircularProgressIndicator();
块之外或if-else
语句中添加else
就可以解决您的问题。
例如。
builder: (context, snapshot) {
if (snapshot.hasError) {
return CircularProgressIndicator();
} else if (snapshot.hasData) {
...
}
else {
return CircularProgressIndicator();
}
按照这些错误提供的说明进行操作可以节省大量时间,并且无需在SO上询问。