我似乎并没有在大纲按钮中找到属性来突出显示或按下时更改文本颜色。
OutlineButton(
child: Text('Delete'),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0)),
borderSide: BorderSide(color: Colors.redAccent),
highlightedBorderColor: Colors.redAccent,
highlightColor: Colors.redAccent,
textColor: Colors.redAccent,
onPressed: () {},
)
我希望此按钮在按下时将文本颜色更改为白色
答案 0 :(得分:2)
我认为最好的选择是从RawMaterialButton
Color buttonColor = Colors.redAccent;
RawMaterialButton(
child: Text(
'Delete',
style: TextStyle(color: buttonColor),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0),
side: BorderSide(color: Colors.redAccent, width: 1)),
fillColor: Colors.transparent,
elevation: 0,
highlightElevation: 0,
splashColor: Colors.black12,
onHighlightChanged: (hc) {
setState(() {
hc
? buttonColor = Colors.white
: buttonColor = Colors.redAccent;
});
},
highlightColor: Colors.red,
onPressed: () {},
)