我试图为我的Flutter应用程序在ThemeData中应用自定义buttonStyle。一切正常,但BorderSide被忽略,并且始终是默认值(BorderSide.color = Colors.black
和BorderSide.width = 1.0
)
如何更改Theme中的BorderSide,使其变为红色,半径为2.0?
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
shape: MaterialStateProperty.resolveWith((states) {
return RoundedRectangleBorder(
// borderRadius is not ignored and gets applied to OutlinedButton => everything fine
borderRadius: BorderRadius.zero,
// here it gets interesting, the side-parameter is always ignored and defaults to `color: Colors.black` and `width: BorderSide.width = 1.0`
side: BorderSide(color: Colors.red, width: 2.0),
);
}),
),
)
字符串
1条答案
按热度按时间643ylb081#
对于任何有同样问题的人,
OutlinedButtonThemeData
有自己的side
参数。BorderSide
必须在那里应用。