Flutter:-在图标周围创建圆形边框

时间:2019-11-07 09:32:32

标签: flutter icons flutter-layout

我想在图标周围创建圆形边框,如图所示。 layout

Container(
              margin: EdgeInsets.all(20),
              padding: EdgeInsets.all(10),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(100),
                color: Colors.white,
                border: Border.all(
                  width: 2
                )
              ),
              child: Icon(Icons.arrow_downward,color: Colors.white,),
            )

我不需要切割图像中显示的圆形边框,而是完整的圆形边框,我也尝试过此代码=> This Answer

4 个答案:

答案 0 :(得分:1)

我认为最简单的方法是使用OutlineButton

OutlineButton(
  onPressed: () { },
  shape: new CircleBorder(),
  borderSide: BorderSide(color: Colors.green),
  child: Icon(
    Icons.print,
    color: Colors.green,
  ),
)

答案 1 :(得分:0)

Container(
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              border: Border.all(color: Colors.white)
            ),
            child: Icon(Icons.check, color: Colors.white,),
          )

或者,如果您需要一些精美的效果,则可以使用Material:

Material(
            color: Colors.transparent,
            shape: CircleBorder(
              side: BorderSide(color: Colors.white)
            ),
            child: Icon(Icons.check, color: Colors.white,),
          )

答案 2 :(得分:0)

我在上面的代码中犯了一些错误。但是我已经知道了,这是新代码。

#include <stdio.h>

int main()
{
    printf("%d");

    return 0;
}

此外,如果您想使完整的Widget可点击,则可以像这样使用它。

Container(
                  margin: EdgeInsets.all(20),
                  padding: EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(100),
                      border: Border.all(width: 2, color: Colors.white)),
                  child: Icon(
                    Icons.cancel,
                    color: Colors.white,
                  ),
                )),

答案 3 :(得分:0)

您也可以使用 $cartdata->balance;