list - 从列表中获取 itemCount
问题描述
我有这个json
结构
"abc":{
current_checklist:[
{
....
},
{
"sections":[
...
]
},
{
...
}
]
}
我想使用ListView
,其中itemCount
基于部分。我应该怎么写?
Widget _displayCheckList(ABCData abcData) {
return ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount:
abcData.abc.currentChecklist.???,length, // how to get the "sections" length?
itemBuilder: (context, index) {
return Text("Hello");
},
);
}
}
解决方案
看到一些有效的示例 json 数据会很好。
您是否尝试过类似的方法:
abcData.abc.currentChecklist[0].sections or
abcData.abc.currentChecklist[1].sections
推荐阅读
- javascript - 在 React Native 中将 props 传递给 HTML 内容
- python-3.x - 如何接管包括空格在内的变量名
- swift - 调整 CollectionView 的单元格大小
- javascript - 如何用scroll-snap实现垂直滚动?
- jquery - 无法使用jquery获取多行表中的输入值
- xpath - 如何获取节点的所有直接父节点的列表?
- python - 模拟 Python 2 `file` 对象的 `fileno` 方法
- javascript - Three.js/A-Frame cubecamera 黑色,物体上没有纹理
- sql - 从 sqlite 获取最新更新的时间戳
- r - 如何将这行代码从 R 更改为 MATLAB?