简体   繁体   中英

How to create circular button with border in Flutter?

I found How to create a circle icon button in Flutter? which has this code:

RawMaterialButton(
  onPressed: () {},
  elevation: 2.0,
  fillColor: Colors.white,
  child: Icon(
    Icons.pause,
    size: 35.0,
  ),
  padding: EdgeInsets.all(15.0),
  shape: CircleBorder(),
)

which works fine, but I can't insert a border with color. Looking on https://api.flutter.dev/flutter/painting/CircleBorder-class.html I cannot find any ways to insert a border.

What's the simplest way to insert a border in a circular button in Flutter?

You can set the border by applying the side property to the CircleBorder. See the code below.

     RawMaterialButton(
      onPressed: () {},
      elevation: 2.0,
      fillColor: Colors.white,
      child: Icon(
        Icons.pause,
        size: 35.0,
      ),
      padding: EdgeInsets.all(15.0),
      shape: CircleBorder(
        side: BorderSide(width: 5, color: Colors.red, style: BorderStyle.solid),
      ),
    );

here is how you can set the border for the button:

shape: CircleBorder(
        side: BorderSide(width: 5.0, style: BorderStyle.solid, color: Colors.red)
      ),

在此处输入图片说明

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