Flutter:将InkWell制作成圆形

4
          Container(
            decoration: BoxDecoration(shape: BoxShape.circle),
            child: Material(
              color: Colors.orange,
              child: InkWell(
                splashColor: Colors.black,
                onTap: () {},
                child: Ink(
                  decoration: BoxDecoration(shape: BoxShape.circle),
                  height: Get.height * 0.0425,
                  width: Get.height * 0.0425,
                  child: Icon(Icons.holiday_village),
                ),
              ),
            ),
          ),

我想将这个InkWell东西变成圆形。似乎没有任何方法可以使其圆形化。如果我去掉Material(),那么它就不会显示背景颜色,也不会出现splash color。我该如何重新设置这个Container-InkWell的形状,以确保按钮是带有splashColor的圆形形状?

1个回答

13

InkWell上使用customBorder: CircleBorder(),在Material上使用shape: const CircleBorder()

Container(
          decoration: BoxDecoration(
            shape: BoxShape.circle,
          ),
          child: Material(
            color: Colors.orange,
            shape: const CircleBorder(),
            child: InkWell(
              splashColor: Colors.black,
              onTap: () {},
              customBorder: const CircleBorder(),
              child: Ink(
                decoration: const BoxDecoration(shape: BoxShape.circle),
                height: 425,
                width: 425,
                child: const Icon(Icons.holiday_village),
              ),
            ),
          ),
        ),

在此输入图像描述


1
customBorder: const CircleBorder()对我来说已经足够了,谢谢 :) - Eng

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接