flutter - Flutter:嵌套 ListView 有效。嵌套的 SliverList 没有,但 ListView 包含 Sliver
问题描述
我遇到了一个特定的问题。我能够组成一个ListView
包含水平ListView
s 的垂直外部。把它想象成 Facebook 上的多个 Friend Suggestion Row 堆叠在一起。这工作正常。
因为我想利用 a 附带的特权SliverAppBar
,所以我需要将 aCustomScrollView
作为父Widget
级,然后在其slivers
集合中只添加 slivers。
当我尝试在 中添加 aSliverList
时SliverChildBuilderDelegate
,我得到了各种各样的错误,主要是与渲染相关的类型错误。似乎对一个SliverChildBuilderDelegate
可以建造的孩子有一个限制。
NEEDS-COMPOSITING-BITS-UPDATE:
needs compositing
creator: Viewport ← IgnorePointer-[GlobalKey#a5a09] ← Semantics ← Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#db221] ← Listener ← _ScrollableScope
← _ScrollSemantics-[GlobalKey#57142] ← Scrollable ← CustomScrollView ← Padding ← ⋯
parentData: <none> (can use size)
constraints: BoxConstraints(w=412.0, 0.0<=h<=Infinity)
size: MISSING
axisDirection: right
crossAxisDirection: down
offset: ScrollPositionWithSingleContext#415a2(offset: 0.0, range: null..null, viewport: null,
ScrollableState, BouncingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#74aea,
ScrollDirection.idle)
anchor: 0.0
This RenderObject had the following child:
center child: RenderSliverList#5219f NEEDS-LAYOUT NEEDS-PAINT
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: RenderBox was not laid out: RenderViewport#e26b4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderViewport#e26b4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#e30f7 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#d70ab relayoutBoundary=up9 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
如您所见,我尝试将 Widget 包装SliverList
在非 sliver 类型的 Widget 中,但无济于事。
我尝试使用它来解决它,NestedScrollView
但我不断收到相同类型的错误。
有没有人遇到过这种情况。我浏览了源代码,我可以看到它ListView
基本上是一个BoxScrollView
带有内部的ScrollView
.
我是否需要创建一个专门的 Widget 来完成这个布局设计。如果是这样的话,我已经对 Flutter 摸不着头脑了。
解决方案
解决了。我所缺乏的只是height
包含width
在Container
我的嵌套SliverList
中。
推荐阅读
- youtube-data-api - 如何授权我的 YouTube API 密钥访问我的 Youtube 频道?
- python - Flutter 客户端无法监听部署在 heroku 上的 Flask socketio 的服务器发射
- pytorch - 在 pytorch 上加载带有错误类的 ImageNet
- c# - 如何以万无一失的方式将Uri转换为字符串
- python - Generating a query string in pyspark and zeppelin notebooks
- java - Hashtable vs ConcurrentHashMap, is the answer correct, why?
- visual-studio-code - “Ctrl + click to follow link” in VSCode terminal to open a Windows File Explorer
- zpl - ZPL - Line Item Detail for Order
- python - 创建带有编号时间窗口的新数据框列
- c++ - ld from other source cannot find a library