flutter - 如何在 Flutter 中创建带边框的圆形按钮?
问题描述
我发现如何在 Flutter 中创建圆形图标按钮?其中有这个代码:
RawMaterialButton(
onPressed: () {},
elevation: 2.0,
fillColor: Colors.white,
child: Icon(
Icons.pause,
size: 35.0,
),
padding: EdgeInsets.all(15.0),
shape: CircleBorder(),
)
效果很好,但我不能插入带颜色的边框。查看https://api.flutter.dev/flutter/painting/CircleBorder-class.html我找不到任何插入边框的方法。
在 Flutter 中的圆形按钮中插入边框的最简单方法是什么?
解决方案
您可以通过将 side 属性应用于 CircleBorder 来设置边框。请参阅下面的代码。
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),
),
);
推荐阅读
- javascript - 如何从 getElementById 获得多个唯一结果?JavaScript
- bash - 将两行的部分提取为一行
- php - 如何在我的 order.php 中插入产品名称、单位名称、价格
- r - 用另一个日期字段替换空白日期字段
- c - 返回 int 的函数上的 C“不应忽略的 void 值”错误
- c# - 使用正则表达式在 C# 中解析字符串
- pdf - 仅禁用嵌入式 PDF 打印和下载选项
- phpmailer - 通过没有 smtp-auth 和代理的 emote sendmail 发送电子邮件
- r - mapedit改变颜色和不透明度
- sql - Oracle 中的 SELECT 计算列