使用横幅轮播时出现空格错误

问题描述 投票:0回答:1

我在容器内使用了横幅旋转木马,但左右有我不想要的间隙

   Container(
                height: Get.height * 0.32,
                decoration: const BoxDecoration(
                  borderRadius: BorderRadius.only(
                    bottomLeft: Radius.circular(25),
                    bottomRight: Radius.circular(25),
                  ),
                ),
                child: BannerCarousel(
                  height: Get.height * 0.32,
                  banners: BannerImages.listBanners,
                  onTap: (id) => print('Tapped on $id'),
                ),
              ),

我尝试更改宽度值,我尝试用填充包裹它并给它一个对称值,我什至尝试给它一个负值

android flutter exception mobile frontend
1个回答
0
投票

赋予

margin
属性并将其设置为
EdgeInsets.zero
,因为默认值为16。您可以从包API参考中看到。

这是结果:

demo

这是最终的代码:

Container(
  height: Get.height * 0.32,
  decoration: const BoxDecoration(
    borderRadius: BorderRadius.only(
      bottomLeft: Radius.circular(25),
      bottomRight: Radius.circular(25),
    ),
  ),
  child: BannerCarousel(
    margin: EdgeInsets.zero, // <----- Add this
    height: Get.height * 0.32,
    banners: BannerImages.listBanners,
    onTap: (id) => print('Tapped on $id'),
  ),
),

希望可以解决您的问题😉

© www.soinside.com 2019 - 2024. All rights reserved.