【问题标题】:How to put Indicator no image flutter如何放置指示器没有图像颤动
【发布时间】:2021-11-21 10:13:03
【问题描述】:

如何穿出像设计一样的形象。我在 youtube 上学习,但教程只有在外面,我尝试使用 Carousel_Pro 但它不能使用,因为它不是 nullSafety 。

Center(
                      child: CarouselSlider(
                    carouselController: _carouselController,
                    options: CarouselOptions(
                        initialPage: 0,
                        height: MediaQuery.of(context).size.height * 0.23,
                        viewportFraction: 1.0,
                        enlargeCenterPage: false,
                        onPageChanged: (index, reason) =>
                            setState(() => activeIndex = index)
                        // autoPlay: false,
                        ),
                    items: imageList
                        .map((item) => Container(
                              child: ClipRRect(
                                  borderRadius: BorderRadius.circular(10.0),
                                  child: SizedBox(
                                      height:
                                          MediaQuery.of(context).size.height *
                                              1,
                                      width:
                                          MediaQuery.of(context).size.width * 1,
                                      child: Image.network(
                                        item,
                                        fit: BoxFit.cover,
                                        height:
                                            MediaQuery.of(context).size.height *
                                                1,
                                      ))),
                            ))
                        .toList(),
                  )),
                  buildIndicator(),

【问题讨论】:

    标签: flutter dart carousel


    【解决方案1】:

    使用Stack 小部件:https://api.flutter.dev/flutter/widgets/Stack-class.html

    它将帮助您将小部件一个叠放在另一个而不是一个叠放在另一个上

    【讨论】:

    • 它的工作谢谢你:>
    【解决方案2】:
    Center(
                          child: CarouselSlider(
                        carouselController: _carouselController,
                        options: CarouselOptions(
                            initialPage: 0,
                            height: MediaQuery.of(context).size.height * 0.23,
                            viewportFraction: 1.0,
                            enlargeCenterPage: false,
                            onPageChanged: (index, reason) =>
                                setState(() => activeIndex = index)
                            // autoPlay: false,
                            ),
                        items: imageList
                            .map((item) => Container(
                                  child: ClipRRect(
                                      borderRadius: BorderRadius.circular(10.0),
                                      child: SizedBox(
                                          height:
                                              MediaQuery.of(context).size.height *
                                                  1,
                                          width:
                                              MediaQuery.of(context).size.width * 1,
                                          child: Image.network(
                                            item,
                                            fit: BoxFit.cover,
                                            height:
                                                MediaQuery.of(context).size.height *
                                                    1,
                                          ))),
                                ))
                            .toList(),
                      )),
                    imageList.lenght> 0?  buildIndicator() : SizedBox(),
    

    【讨论】:

      猜你喜欢
      • 2021-03-10
      • 2019-02-09
      • 2023-04-11
      • 2021-06-24
      • 2021-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      相关资源
      最近更新 更多