【发布时间】:2021-08-31 11:43:40
【问题描述】:
【问题讨论】:
-
backgroundColor: MaterialStateProperty.all(Colors.red),应该将您的按钮显示为红色。
标签: function flutter dart button colors
【问题讨论】:
backgroundColor: MaterialStateProperty.all(Colors.red), 应该将您的按钮显示为红色。
标签: function flutter dart button colors
没有颜色你会影响颜色
backgroundColor: MaterialStateProperty.all(color)
【讨论】:
这样就可以了
backgroundColor: MaterialStateProperty.all(Colors.red), // Or whatever color
但如果您需要更多控制权。这样做
MaterialStateProperty.resolveWith<Color>(
(states) {
if (states.contains(MaterialState.disabled)) {
return greyColor;
}else if (states.contains(MaterialState.error)) {
return Colors.red;
}
// Check other stated too. As per your need
return selectedPrimaryColor;
},
),
【讨论】: