小编fli*_*itz的帖子

Flutter carousel 图像滑块在点击事件期间打开单独的页面被称为

我是新来的颤振。我想问一个关于我的代码的问题。我查看了 youtube 和一些关于此墨水池和点击功能的谷歌教程,以在颤振上打开新的类活动。但结果是,当点击图像时,它会打开不同的图像屏幕,但它们共享相同的类文件。

如何为不同的图像点击创建单独的页面。例如,我的 flutter carousel 滑块中有五个图像。Image 1 将打开sliderpage 1。Image 2 将打开sliderpage 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(),
       )


        ],
      ),
    );
  }
} …
Run Code Online (Sandbox Code Playgroud)

dart flutter

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

dart ×1

flutter ×1