在 ListView.builder 上多次使用相同的索引
same index multiple times on ListView.builder
我想显示 2 个自定义小部件和列表视图(api 数据)。我不能使用 column
。(因为我想滚动一次)
这里缺少来自api
的0和1数据
ListView.builder(
itemCount: get.length,//3
itemBuilder: (BuildContext context, int index) {
if(index == 0){
return Text('Generate By Developer');
}
if(index == 1){
return Text('Generate By Developer');
}
return Bubble(
style: styleSomebody,
child: Container(
...
));
}),
只需调整计数和索引即可。
ListView.builder(
itemCount: get.length + 2, // add room for the two extra
itemBuilder: (BuildContext context, int index) {
if(index == 0){
return Text('Generate By Developer');
}
if(index == 1){
return Text('Generate By Developer');
}
index -= 2; // decrement index so that it's now in the range [0..length]
return Bubble(
style: styleSomebody,
child: Container(
...
));
}),
我想显示 2 个自定义小部件和列表视图(api 数据)。我不能使用 column
。(因为我想滚动一次)
这里缺少来自api
的0和1数据 ListView.builder(
itemCount: get.length,//3
itemBuilder: (BuildContext context, int index) {
if(index == 0){
return Text('Generate By Developer');
}
if(index == 1){
return Text('Generate By Developer');
}
return Bubble(
style: styleSomebody,
child: Container(
...
));
}),
只需调整计数和索引即可。
ListView.builder(
itemCount: get.length + 2, // add room for the two extra
itemBuilder: (BuildContext context, int index) {
if(index == 0){
return Text('Generate By Developer');
}
if(index == 1){
return Text('Generate By Developer');
}
index -= 2; // decrement index so that it's now in the range [0..length]
return Bubble(
style: styleSomebody,
child: Container(
...
));
}),