考虑下面这个build()
函数:
Widget build(BuildContext context){
return MaterialApp(
home: Scaffold(
body: Center(
child: ListView.builder(
itemCount: 6,
itemBuilder: (context, i){
if(numberTruthList[i]){
return ListTile(
title: Text("$i"),
);
}
},
),
)
),
);
}
如果numberTruthList是这样的:List<bool> numberTruthList = [true, true, true, true , true, true];
,那么输出结果将会是:而如果numberTruthList是这样的:List<bool> numberTruthList = [false, true, true, true , true, true];
,输出结果将会是:我希望输出结果为一个ListView,其中包含以下项目: ListTile( title: Text("$i"),);
对于使得numberTruthList[i]为true的i的取值,应该编写什么代码?