dart OutlinedButtonThemeData => Borderside.color中忽略OutlinedButtonBorderSide,BorderSide.width始终为默认值

sczxawaw  于 2023-11-14  发布在  其他
关注(0)|答案(1)|浏览(88)

我试图为我的Flutter应用程序在ThemeData中应用自定义buttonStyle。一切正常,但BorderSide被忽略,并且始终是默认值(BorderSide.color = Colors.blackBorderSide.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),
      );
    }),
  ),
)

字符串

643ylb08

643ylb081#

对于任何有同样问题的人,OutlinedButtonThemeData有自己的side参数。BorderSide必须在那里应用。

相关问题