这个 widget 在 flutter 中叫什么?

What is this widget called in flutter?

谁能告诉我这是 flutter 中的什么小部件。 图片来源亚马逊

使用了几个小部件来获得此结果: PageView

Image // Image.asset 或 Image.network 或其他

为了显示当前图片的索引,使用了ListViewContainer

旋转木马图片滑块! 你可以在这里找到它: https://pub.dev/packages/carousel_slider

正如 Peter Haddad 在评论中提到的那样,https://pub.dev/packages/carousel_slider 是执行此操作的最佳软件包。这是有关如何执行此操作的示例
首先在 dependencies

下的 pubspec.yaml 添加库
  carousel_slider: ^3.0.0

那你可以用这个

class CarouselWithIndicatorDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _CarouselWithIndicatorState();
  }
}

class _CarouselWithIndicatorState extends State<CarouselWithIndicatorDemo> {
  int _current = 0;
  List<String> imgList = [
  'https://images.unsplash.com/photo-1520342868574-5fa3804e551c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6ff92caffcdd63681a35134a6770ed3b&auto=format&fit=crop&w=1951&q=80',
  'https://images.unsplash.com/photo-1522205408450-add114ad53fe?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=368f45b0888aeb0b7b08e3a1084d3ede&auto=format&fit=crop&w=1950&q=80',
  'https://images.unsplash.com/photo-1519125323398-675f0ddb6308?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=94a1e718d89ca60a6337a6008341ca50&auto=format&fit=crop&w=1950&q=80',
  'https://images.unsplash.com/photo-1523205771623-e0faa4d2813d?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=89719a0d55dd05e2deae4120227e6efc&auto=format&fit=crop&w=1953&q=80',
  'https://images.unsplash.com/photo-1508704019882-f9cf40e475b4?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=8c6e5e3aba713b17aa1fe71ab4f0ae5b&auto=format&fit=crop&w=1352&q=80',
  'https://images.unsplash.com/photo-1519985176271-adb1088fa94c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a0c8d632e977f94e5d312d9893258f59&auto=format&fit=crop&w=1355&q=80'
];//Use any photos u want
  @override
  Widget build(BuildContext context) {
    return Container(
       width:MediaQuery.of(context).size.width,//Fills the page horizontally
       child:Stack(
        children: [
          CarouselSlider(
            items: imageSliders,
            options: CarouselOptions(
              autoPlay: true,
              enlargeCenterPage: true,
              aspectRatio: 2.0,
              onPageChanged: (index, reason) {
                setState(() {
                  _current = index;
                });
              }
            ),
          ),
         Column(
          mainAxisAlignment:MainAxisAlignment.end
          children:<Widget>[
           Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: imgList.map((url) {
              int index = imgList.indexOf(url);
              return Container(
                width: 14.0,
                height: 14.0,
                margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 2.0),
                decoration: BoxDecoration(
                  shape: BoxShape.circle,
                  color: _current == index
                    ? Colors.white,
                    : Color.grey[400],
                ),
              );
            }).toList(),
          ),
          SizedBox(height:30),
          ],
         ),
        ]
    );
  }
}