【发布时间】:2019-08-20 03:56:25
【问题描述】:
我是新来的颤振。我想问一个关于我的代码的问题。我在 youtube 和一些谷歌教程上查看了这个 inkwell 和点击功能以在颤振上打开新的课程活动。但结果是,当点击图像时,它会打开不同的图像屏幕,但它们共享相同的类文件。
如何为不同的图片点击设置单独的页面。例如, 我的颤动轮播滑块中有五个图像。 图像 1 将打开滑块页面 1。图像 2 将打开滑块页面 2,依此类推。表示它们在单独的页面上,而不是不同的图像打开同一页面,但只显示不同的图像。我正在尝试本教程,但它们确实具有相同的页面,但在调用点击事件后显示的图像不同。网址https://www.youtube.com/watch?v=l9XOUoJsdy4
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
Widget image_carousel = new Container(
height: 345.0,
child: new Carousel(
boxFit: BoxFit.fill,
images: [
AssetImage('assets/s7.jpg'),
AssetImage('assets/s3.jpg'),
AssetImage('assets/s5.jpg'),
AssetImage('assets/s2.jpg'),
AssetImage('assets/s4.jpg'),
],
autoplay: true,
animationCurve: Curves.fastOutSlowIn,
animationDuration: Duration(milliseconds: 500),
dotColor: Colors.red[50],
dotSize: 4.0,
indicatorBgPadding: 2.0,
),
);
return Scaffold(
body: new Column(
children: <Widget>[
image_carousel,
//grid view
Container(
height:163.0,
child: Products(),
)
],
),
);
}
}
在此代码中,此代码仅显示轮播图像,没有任何点击事件完成,我希望在点击图像资产并导航到不同页面时发生点击事件时会发生不同的页面路由。
【问题讨论】: