旧版本:
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),
),
),
),
)
要更改 Flutter 中
OutlinedButton
的边框颜色,您可以在 side
方法中使用 OutlinedButton.styleFrom
属性。
OutlinedButton.icon(
onPressed: () {},
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: const BorderSide(
color: Colors.blue,
width: 2,
), // Border color and width
),
icon: const Icon(
Icons.arrow_right_alt,
),
label: const Text("Los geht's"),
)