flutter - Flutter:更改轮廓按钮的边框颜色
问题描述
旧版:
OutlineButton.icon(
textColor: Theme.of(context).primaryColorDark,
icon: Icon(Icons.person_add),
label: Text(translate('contacts_list.import')),
shape: new RoundedRectangleBorder(
borderSide: BorderSide(
color: Colors.red,
style: BorderStyle.solid,
width: 1,
),
);
新版本:
OutlinedButton.icon(
onPressed: () async {},
icon: Icon(Icons.person_add),
label: Text("Import"),
style: OutlinedButton.styleFrom(
backgroundColor: Colors.white,
primary: Theme.of(context).primaryColorDark,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(2),
),
),
),
)
我不知道如何更改边框颜色。这里有一个例子,但与此效果无关:https ://docs.google.com/document/d/1yohSuYrvyya5V1hB6j9pJskavCdVq9sVeTqSoEPsWH0/edit
解决方案
你可以这样做side: BorderSide()
例子:
OutlinedButton.icon(
onPressed: () async {},
icon: Icon(Icons.person_add),
label: Text("Import"),
style: OutlinedButton.styleFrom(
side: BorderSide(width: 2, color: Colors.green),
backgroundColor: Colors.white,
primary: Theme.of(context).primaryColorDark,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(2),
),
),
),
)
推荐阅读
- casbin - 如何基于多组成员身份使用 Casbin 保护资源
- postgresql - 如何通知 pod(s) 其他副本 pod 的 IP 地址
- python - 如何在另一个文件夹中导入 Python 模块,而无需相对导入和编辑 PYTHONPATH
- python - 如何将列表:numpy.int64 实例转换为 model.fit 的(稀疏/二进制)分类格式?
- javascript - Pug 多次打印相同的值
- node.js - 测试函数是否已运行的问题
- design-patterns - 我们如何实现有状态的访问者模式?
- api - 是否有任何静态代码分析工具来验证 API REST 指南?
- html - svg中线性渐变颜色的悬停事件
- javascript - 在容器内使用 fullpage.js