【问题标题】:How to Navigate to other Screen using Carousel如何使用轮播导航到其他屏幕
【发布时间】:2020-09-24 22:07:56
【问题描述】:

我想要一个有 5 张照片的轮播,当我按下任何一张图片时,我想导航到另一个屏幕。我看了很多视频,但找不到任何解决方案。我使用了carousel_slider 包。

CarouselSlider(
  CarouselOptions(height: 400.0),
  items: [1,2,3,4,5].map((i) {
    return Builder(
      builder: (BuildContext context) {
        return Container(
          width: MediaQuery.of(context).size.width,
          margin: EdgeInsets.symmetric(horizontal: 5.0),
          decoration: BoxDecoration(
            color: Colors.amber
          ),
          child: Text('text $i', style: TextStyle(fontSize: 16.0),)
        );
      },
    );
  }).toList(),
)

假设我有 5 个不同的页面,当我按下轮播中的任何图片时,我应该被导航到特定页面。如果我使用手势检测器,如何使用 navigator.push 导航他?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    尝试使用 ManuallyControlledSlider https://github.com/serenader2014/flutter_carousel_slider/blob/master/example/lib/main.dart 但在内部更改 onPressed 回调 Iterable -> RaisedButton 在特定页面上导航。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-21
      • 2020-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多