简体   繁体   中英

How can i put Dot Indicator above Carousel slider in flutter,i tried with stack to position it above the carousel image but its not working

Stack(children: [
          CarouselSlider.builder(
              carouselController: controller,
              itemCount: images.length,
              itemBuilder: (context, index, realIndex) {
                final image = images[index];
                return BuildImage(image, index);
              },
              options: CarouselOptions(
                viewportFraction: 1,
                height: 200,
                initialPage: 0,
                reverse: false,
                autoPlay: true,
              )),
          Container(alignment: Alignment.bottomCenter, child: buildIndicator()),
        ],),

在此处输入图像描述

Try Positioned like this:

Stack(
            children: [
              CarouselSlider.builder(
                        carouselController: controller,
                        itemCount: images.length,
                        itemBuilder: (context, index, realIndex) {
                          final image = images[index];
                          return BuildImage(image, index);
                        },
                        options: CarouselOptions(
                          viewportFraction: 1,
                          height: 200,
                          initialPage: 0,
                          reverse: false,
                          autoPlay: true,
                        )),
              Positioned(
                left: 0,
                right: 0,
                bottom: 10,
                child: buildIndicator(),
              ),
            ],
          ),

Give alignment to stack widget...

Stack(
      alignment: AlignmentDirectional.bottomCenter,
      children: [...]
      )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM