gpt4 book ai didi

android - Flutter Container BoxShadow 不显示

转载 作者:IT王子 更新时间:2023-10-29 06:53:20 24 4
gpt4 key购买 nike

这是我此刻的代码:

ClipRRect(
borderRadius: BorderRadius.circular(11),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: FractionalOffset.bottomLeft,
end: FractionalOffset.topRight,
colors: <Color>[Colors.purple, AppBaseColors.orange],
),
boxShadow: [BoxShadow(color: Colors.yellow)]
),
child: Material(
child: InkWell(
onTap: () {
print("tapped");
},
child: Container(
width: ButtonTheme.of(context).minWidth,
height: ButtonTheme.of(context).height,
child: Center(
child: Text(
"log in",
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
),
),
color: Colors.transparent,
),
),
),

我尝试了什么:

  • 在第一个Container中添加boxShadow
  • 在第二个Container中添加boxShadow
  • 添加另一个带有 boxShadowContainer 作为 ClipRRect 的父级
  • Material 中添加 boxShadow 作为 shadowColor(ofc 不起作用,因为我没有任何类型的阴影)
  • 在上述所有情况下还添加了 spreadRadiusblurRadius,但没有任何改变。

知道我做错了什么吗?

最佳答案

您需要进行这些更改:

  • 删除 ClipRRect 小部件。
  • BoxDecoration 中添加 borderRadius
  • 向您的 BoxShadow 添加一个 Offset

    Container(
    decoration: BoxDecoration(
    color: Colors.blue,
    gradient: LinearGradient(
    begin: FractionalOffset.bottomLeft,
    end: FractionalOffset.topRight,
    colors: <Color>[Colors.purple, Colors.orange],
    ),
    borderRadius: BorderRadius.circular(11),
    boxShadow: [
    BoxShadow(color: Colors.yellow, offset: Offset(5.0, 5.0))
    ]),
    child: Material(
    borderRadius: BorderRadius.circular(11),
    clipBehavior: Clip.hardEdge,
    child: InkWell(
    onTap: () {
    print("tapped");
    },
    child: Container(
    width: ButtonTheme.of(context).minWidth,
    height: ButtonTheme.of(context).height,
    child: Center(
    child: Text(
    "log in",
    style: TextStyle(
    color: Colors.white, fontWeight: FontWeight.bold),
    ),
    ),
    ),
    ),
    color: Colors.transparent,
    ),
    ),

关于android - Flutter Container BoxShadow 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55955383/

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