简体   繁体   English

SliverList SliverChildBuilderDelegate 中的 ListView.builder 在第一次加载时不渲染图像

[英]ListView.builder inside SliverList SliverChildBuilderDelegate not rendering Images on first load

my images (from api) don't render at first load unless I scroll down and back to top again我的图像(来自 api)不会在第一次加载时呈现,除非我向下滚动并再次返回顶部

here is my code structure这是我的代码结构

CustomScrollView(
 slivers: [
     SliverList(
       delegate: SliverChildBuilderDelegate(_, index) {
        return Column(children: 
                     [
                     // SLIVERBUILDER INDEX
                     Text(somedata[_index]),
                     // MY IMAGE BUILDER
                     Container(child: ListView.builder(itemBuilder: (_, int index){
                                        return Image.network(arrayOfImages[index]);
                                      }))
                     ]
               );
     }),
 ]
)

Try these:试试这些:

  1. Wrap a column with a container or any parent that could give its child constraints.用容器或任何可以为其子项提供约束的父项包裹一列。
 SliverList( delegate: SliverChildBuilderDelegate( (context, index) { return Container( // warp with container height: 450, child: Column(children: [ // SLIVERBUILDER INDEX Text('title'),
  1. Wrap ListView.builder with Expanded and add itemCount Property.用 Expanded 包裹 ListView.builder 并添加 itemCount 属性。 (In your case 'arrayOfImage.length') (在你的情况下'arrayOfImage.length')
 // MY IMAGE BUILDER Expanded( // add this widget child: ListView.builder( itemCount: arrayOfImage.length, // add this line

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM