gpt4 book ai didi

flutter - 无法更改 OutlinedButton 中的边框颜色

转载 作者:行者123 更新时间:2023-12-05 08:22:01 25 4
gpt4 key购买 nike

我正在尝试更改 main.dart 中的 OutlinedButton 的边框,但它似乎不起作用。我环顾四周,似乎我需要添加 BorderSide。这是我的 outlinedButtonTheme 的样子:

              outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return AppColors.SecondaryButtonPressed;
}

return AppColors.SecondaryButton;
},
),
minimumSize: MaterialStateProperty.all<Size>(Size(335, 60)),
shape: MaterialStateProperty.all<OutlinedBorder>(
RoundedRectangleBorder(
side: BorderSide(
style: BorderStyle.solid,
color: AppColors.Primary,
width: 1), // <-- this doesn't work?
borderRadius: BorderRadius.all(Radius.circular(12)),
)),
foregroundColor: MaterialStateProperty.all<Color>(
AppColors.SecondaryButtonText),
textStyle: MaterialStateProperty.all<TextStyle>(TextStyle(
color: AppColors.SecondaryButtonText,
fontSize: 14 * FONT_SCALE_FACTOR,
fontWeight: FontWeight.w600,
)),
),
),

如上所示,BorderSide 所在的位置。这似乎根本不起作用。

最佳答案

这对我有用:

OutlinedButton(onPressed: () {},
style: ButtonStyle(shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0))),
side: MaterialStateProperty.all(BorderSide(
color: AppColors.blue,
)),
),)

关于flutter - 无法更改 OutlinedButton 中的边框颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66678974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com