gpt4 book ai didi

flutter - 如何在 Flutter 中的按钮周围添加阴影?

转载 作者:行者123 更新时间:2023-12-03 02:59:47 25 4
gpt4 key购买 nike

我正在尝试重新创建一个类似于下图所示的按钮。但是我无法在它后面添加微弱的阴影。
这就是我想要实现的目标:
enter image description here
这是我的按钮的样子:
enter image description here
这是我的代码:

                Container(
height: 45,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFFFF8C3B),
Color(0xFFFF6365),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: const BorderRadius.all(
Radius.circular(25.0),
),
),
child: Center(
child: GestureDetector(
onTap: () {},
child: Text(
'Create Account',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: "Netflix",
fontWeight: FontWeight.w600,
fontSize: 18,
letterSpacing: 0.0,
color: Colors.white,
),
),
),
),
),

最佳答案

您可以为 Container 添加粉红色阴影:

Container(
height: 60,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromRGBO(255, 143, 158, 1),
Color.fromRGBO(255, 188, 143, 1),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: const BorderRadius.all(
Radius.circular(25.0),
),
boxShadow: [
BoxShadow(
color: Colors.pink.withOpacity(0.2),
spreadRadius: 4,
blurRadius: 10,
offset: Offset(0, 3),
)
]
),
child: Center(
child: GestureDetector(
onTap: () {},
child: Text(
'Create Account',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: "Netflix",
fontWeight: FontWeight.w600,
fontSize: 18,
letterSpacing: 0.0,
color: Colors.white,
),
),
),
),
),
注意:我还更改了渐变颜色,使其看起来更像图片。
结果:
res

关于flutter - 如何在 Flutter 中的按钮周围添加阴影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63315052/

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