Mar*_*yns 6 flutter flutter-sliver flutter-layout
Can a layout like this be achieved and rendered efficiently in Flutter?
Example:
Yellow and blue blocks can both be around 30 elements, so I guess something like ListView.builder should be used.
I have tried nesting 2 ListView.builder, the inner with shrinkWrap = true. The yellow block is being built just when is needed, but the blue list, although it has an itemBuilder, it builds all children elements at once, causing performance problems.
new ListView.builder(
itemCount: 20,
itemBuilder: (BuildContext context, int blockIdx) {
print("Building block $blockIdx");
return new Column(
children: [
Padding(
child: Text("Block $blockIdx"),
padding: EdgeInsets.all(8.0)
),
ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
itemCount: 30,
itemBuilder: (BuildContext context, int childIdx) {
print("Building block $blockIdx child $childIdx");
return Padding(
child: Text("Child $childIdx"),
padding: EdgeInsets.only(left: 20.0, right: 8.0, top: 8.0, bottom: 8.0),
);
},
);
],
);
},
);
Run Code Online (Sandbox Code Playgroud)
Thanks in advance.
| 归档时间: |
|
| 查看次数: |
1165 次 |
| 最近记录: |