gpt4 book ai didi

Flutter:如何修复轮廓按钮并为其添加边框和颜色?

转载 作者:行者123 更新时间:2023-12-02 02:07:53 26 4
gpt4 key购买 nike

有人能告诉我为什么我的代码没有将边框设为蓝色,而是让它的宽度为 3.0 吗?

这是它的样子(L:我的应用程序,R:教程应用程序): enter image description here

代码:

class CreateRoomButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return OutlinedButton(
onPressed: () => print('Create Room'),
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
side: BorderSide(
color: Colors.blueAccent[100],
width: 3.0,
),
borderRadius: BorderRadius.circular(30.0),
),
),
),
child: Row(
children: [
ShaderMask(
shaderCallback: (rect) =>
Palette.createRoomGradient.createShader(rect),
child: Icon(
Icons.video_call,
color: Colors.white,
size: 35.0,
),
),
const SizedBox(width: 4.0),
Text(
'Create\nRoom',
style: TextStyle(color: Colors.blueAccent[100]),
),
],
),
);
}
}

此外,我还必须在某处添加它(但由于 textColor 在 flutter 2.0 中已贬值,我不知道如何处理它...):

textColor: Palette.facebookblue,

谢谢!

最佳答案

只需将您的 OutlinedButton 更改为:

OutlinedButton(
onPressed: () => print('Create Room'),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
side: BorderSide(width: 3.0, color: Colors.blueAccent[100]),
)
child: yourChildWidget,
)

关于Flutter:如何修复轮廓按钮并为其添加边框和颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68146283/

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