Exception when using SliverStaggeredGrid
Closed this issue · 3 comments
gosoares commented
Code causing the issue:
CustomScrollView(
controller: controller,
slivers: <Widget>[
SliverToBoxAdapter(
child: widget.top ?? Container(),
),
SliverStaggeredGrid.countBuilder(
crossAxisCount: 2,
staggeredTileBuilder: (_) => StaggeredTile.fit(1),
itemBuilder: (context, index) => ProductGridItem(product: products[index],),
itemCount: products.length,
),
SliverToBoxAdapter(
child: StreamBuilder<DataStatus>(
stream: productListBloc.dataStatus,
builder: (context, snapshot) => _buildStatusIndicator(snapshot?.data),
),
)
],
);
Full stack trace:
I/flutter (17730): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (17730): The following assertion was thrown during performLayout():
I/flutter (17730): StatefulWidget.createState must return a subtype of State<AutomaticKeepAliveVariableSizeBox>
I/flutter (17730): The createState function for AutomaticKeepAliveVariableSizeBox returned a state of type
I/flutter (17730): _AutomaticKeepAliveState, which is not a subtype of State<AutomaticKeepAliveVariableSizeBox>,
I/flutter (17730): violating the contract for createState.
I/flutter (17730):
I/flutter (17730): When the exception was thrown, this was the stack:
I/flutter (17730): #0 new StatefulElement.<anonymous closure> (package:flutter/src/widgets/framework.dart:3713:9)
I/flutter (17730): #1 new StatefulElement (package:flutter/src/widgets/framework.dart:3721:6)
I/flutter (17730): #2 StatefulWidget.createElement (package:flutter/src/widgets/framework.dart:789:42)
I/flutter (17730): #3 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2905:40)
I/flutter (17730): #4 Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter (17730): #5 SliverVariableSizeBoxAdaptorElement.updateChild (package:flutter_staggered_grid_view/src/widgets/sliver.dart:377:36)
I/flutter (17730): #6 SliverVariableSizeBoxAdaptorElement.createChild.<anonymous closure> (package:flutter_staggered_grid_view/src/widgets/sliver.dart:361:20)
I/flutter (17730): #7 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2222:19)
I/flutter (17730): #8 SliverVariableSizeBoxAdaptorElement.createChild (package:flutter_staggered_grid_view/src/widgets/sliver.dart:357:11)
I/flutter (17730): #9 RenderSliverVariableSizeBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:240:23)
I/flutter (17730): #10 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1666:58)
I/flutter (17730): #11 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:740:15)
I/flutter (17730): #12 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1666:13)
I/flutter (17730): #13 RenderSliverVariableSizeBoxAdaptor._createOrObtainChild (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:228:5)
I/flutter (17730): #14 RenderSliverVariableSizeBoxAdaptor.addAndLayoutChild (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:305:5)
I/flutter (17730): #15 RenderSliverStaggeredGrid.performLayout (package:flutter_staggered_grid_view/src/rendering/sliver_staggered_grid.dart:317:17)
I/flutter (17730): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #17 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:336:13)
I/flutter (17730): #18 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1131:12)
I/flutter (17730): #19 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1049:20)
I/flutter (17730): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #21 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #23 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #29 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:109:13)
I/flutter (17730): #36 RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter (17730): #37 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:141:11)
I/flutter (17730): #38 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:399:7)
I/flutter (17730): #39 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:211:7)
I/flutter (17730): #40 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:355:14)
I/flutter (17730): #41 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1445:7)
I/flutter (17730): #42 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:709:18)
I/flutter (17730): #43 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270:19)
I/flutter (17730): #44 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:627:13)
I/flutter (17730): #45 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
I/flutter (17730): #46 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (17730): #47 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (17730): #48 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (17730): #49 _invoke (dart:ui/hooks.dart:120:13)
I/flutter (17730): #50 _drawFrame (dart:ui/hooks.dart:109:3)
I/flutter (17730):
I/flutter (17730): The following RenderObject was being processed when the exception was fired:
I/flutter (17730): RenderSliverStaggeredGrid#6ff68 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17730): creator: SliverStaggeredGrid ← Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#0c820] ←
I/flutter (17730): Semantics ← Listener ← _GestureSemantics ←
I/flutter (17730): RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#32677] ←
I/flutter (17730): _ExcludableScrollSemantics-[GlobalKey#b83f0] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ← ⋯
I/flutter (17730): parentData: paintOffset=Offset(0.0, 0.0) (can use size)
I/flutter (17730): constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle,
I/flutter (17730): scrollOffset: 0.0, remainingPaintExtent: 560.0, crossAxisExtent: 360.0, crossAxisDirection:
I/flutter (17730): AxisDirection.right, viewportMainAxisExtent: 560.0, remainingCacheExtent: 810.0 cacheOrigin: 0.0 )
I/flutter (17730): geometry: null
I/flutter (17730): no children current live
I/flutter (17730): This RenderObject has no descendants.
I/flutter (17730): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (17730): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter (17730): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
letsar commented
I updated the package to 0.2.1. This should be fixed.
gosoares commented
Yes, it's working. Thanks for this awesome library. :)
letsar commented
You're welcome, thanks 😄