【问题标题】:get itemCount from a list从列表中获取 itemCount
【发布时间】:2021-02-14 05:38:41
【问题描述】:

我有这个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");
      },
    );
  }
}

【问题讨论】:

  • sections 是仅在current_checklist 的一个对象中可用还是在所有对象中都可用?
  • @RaviSinghLodhi 所有人

标签: list flutter listview dart


【解决方案1】:

如果能看到一些有效的示例 json 数据会很好。

您是否尝试过类似的方法:

abcData.abc.currentChecklist[0].sections or
abcData.abc.currentChecklist[1].sections

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 2019-12-31
    • 2013-02-19
    • 2015-11-27
    • 2012-04-04
    • 2017-06-09
    相关资源
    最近更新 更多