您可以将或包装
GridTile在
InkResponse或中,
GestureDetector然后传递一个要在单击时调用的函数
例:
// Function to be called on clickvoid _onTileClicked(int index){ debugPrint("You tapped on item $index");}// Get grid tilesList<Widget> _getTiles(List<File> iconList) { final List<Widget> tiles = <Widget>[]; for (int i = 0; i < iconList.length; i++) { tiles.add(new GridTile( child: new InkResponse( enableFeedback: true, child: new Image.file(iconList[i], fit: BoxFit.cover,), onTap: () => _onTileClicked(i), ))); } return tiles;}// GridViewnew GridView.count( crossAxisCount: 4, childAspectRatio: 1.0, padding: const EdgeInsets.all(4.0), mainAxisSpacing: 4.0, crossAxisSpacing: 4.0, children: _getTiles(_imageList),)
希望有帮助!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)