嗨,我设计了一个用 flatbutton 包装的列表视图,但是单击下面的列表视图后我无法获取索引是代码。我被 GestureDetector 包裹着。
List<GestureDetector> _buildListItemsfromFlower() {
return ExcerciselistPojo.randomList.map((flowers) {
var flatbutton = GestureDetector(
child: Card(
elevation: 2.0,
child: new Row(
textBaseline: TextBaseline.alphabetic,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Container(
child: new Column(
children: <Widget>[
new Container(
width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height / 15,
margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
child: new Text(
flowers.name,
style: TextStyle(
color: Colors.black,
fontSize: 20,
decoration: TextDecoration.none),
),
),
new Container(
margin: EdgeInsets.fromLTRB(15, 10, 0, 0),
width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height / 15,
child: new Text(
flowers.duration,
style: TextStyle(
color: Colors.pink,
fontSize: 20,
decoration: TextDecoration.none),
)),
],
)),
new Container(
margin: new EdgeInsets.fromLTRB(55, 0, 0, 0),
child: ImageSequenceAnimator(
"assets/images/" + flowers.imageUrl,
"Pic_",
0,
5,
"webp",
3,
isAutoPlay: true,
color: null,
fps: 2,
isBoomerang: false,
isLooping: true,
),
width: 80,
height: 80,
),
],
)));
return GestureDetector(
child: flatbutton,
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ExcerciseDetails(
ExcerciselistPojo.randomList[2].name,
ExcerciselistPojo.randomList[2].image,
ExcerciselistPojo.randomList[2].description),
));
},
);
}).toList();
}
我想下一个带有索引值的飞镖文件。单击上面的列表视图后,请告诉我如何获取索引值。