How to set image from API to Carousel in Flutter

那年仲夏 提交于 2021-02-07 10:56:08

问题


I want to use a Banner Slider in Flutter apps, so I found a library to make it, namely Carousel. This is a good library but I found a problem for this library, How to set image from API into Carousel? or have any library for support image from API (list), have dot indicator, autoplay like Carousel?


回答1:


Use Carousel package -: carousel_slider: ^1.3.0

    CarouselSlider(
          autoPlay: true,
          pauseAutoPlayOnTouch: Duration(seconds: 5),
          height: MediaQuery.of(context).size.height * 0.60,
          items: <Widget>[
            for (var i = 0; i < image.length; i++)
              Container(
                  margin: const EdgeInsets.only(top: 20.0, left: 20.0),
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: NetworkImage(image[i]),
                      fit: BoxFit.fitHeight,
                    ),
                    // border:
                    //     Border.all(color: Theme.of(context).accentColor),
                    borderRadius: BorderRadius.circular(32.0),
                  ),
                ),                                     
          ],
        ),


来源:https://stackoverflow.com/questions/57258813/how-to-set-image-from-api-to-carousel-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!