我有一个数组,其中包含显示给用户的图像。当用户滑动图像时,我希望将图像从阵列中删除,以使他们无法再次看到它,然后显示新图像。
用户可以拖动图像,并在其下方显示图像。
我遇到的问题是,当我从数组中删除项目0时,最初显示在项目0下面的图像不会显示,而是显示项目2。
我了解为什么会这样,我想知道是否有人对此有解决方案。这是当前代码:
Swiper(
outer: false,
itemBuilder: (BuildContext context, int index) {
return new Column(
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Stack(
children: <Widget>[
new Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.pink[250],
width: 7,
),
borderRadius: BorderRadius.circular(9),
),
child: new Container(
child: new Image.asset(dateIdeas[index]['Image']),
),
),
Positioned.fill(
child: Container(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.only(
left: 10.0, bottom: 10.0),
child: Text(dateIdeas[index]['Description'],
style: TextStyle(
fontSize: 30,
color: Colors.white,
fontFamily: 'IndieFlower',
shadows: [
Shadow(
// bottomLeft
offset: Offset(-2.5, -2.5),
color: Colors.black),
Shadow(
// bottomRight
offset: Offset(1.5, -1.5),
color: Colors.black),
Shadow(
// topRight
offset: Offset(1.5, 1.5),
color: Colors.black),
Shadow(
// topLeft
offset: Offset(-1.5, 1.5),
color: Colors.black),
],
)),
),
),
),
],
),
],
)
],
);
},
itemCount: dateIdeas.length,
layout: SwiperLayout.STACK,
itemHeight: 600,
itemWidth: 375,
loop: true,
onIndexChanged: (int index) {
setState(() {
dateIdeas.removeAt(0);
});
},
),