我想通过单击和拖动滚动行中的项目。当我尝试通过单击和拖动滚动时,它什么也不做..................................................................................................... .......
Container(
height: 300,
width: double.infinity,
color: Colors.green,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(
services.length, (index) => GalleryCard(index: index)),
),
),
)
这是画廊卡类:
class GalleryCard extends StatefulWidget {
const GalleryCard({
Key? key,
required this.index,
}) : super(key: key);
final int index;
@override
_GalleryCardState createState() => _GalleryCardState();
}
class _GalleryCardState extends State<GalleryCard> {
@override
Widget build(BuildContext context) {
return Row(
children: [
SizedBox(
height: 300,
width: 340,
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.asset(
recentWorks[widget.index].image,
fit: BoxFit.fill,
),
),
),
],
);
}
}
2条答案
按热度按时间oxiaedzo1#
通过使用下面的你可以滚动点击和拖动它,甚至滚动鼠标滚轮
使用此自定义类
上述小部件类的用法
wlwcrazw2#
初始化选项卡控制器:
工作起来很有魅力。