颤振边框卡的半径不适用于子:容器?



我有以下代码,我想知道如何让Container接受Cards BorderRadius?我知道的唯一方法是将BorderRadius添加到容器的BoxDecoration中,但这是正确的方法吗?我怎么能做得更好?

Align(
child: Card(
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xff232526),Color(0xff414345) ],
begin: Alignment.bottomCenter,
// stops: [0.1,1],
end: Alignment.topCenter,
),
),
child: RadialGauge(
counter: snapshot.data['Strom'].toDouble(),
).buildGauge(),
),
),
),

您可以使用Clip.hardEdge,将多余的剪切掉

Card(
clipBehavior: Clip.hardEdge,
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
child:...

在您的箱子中集装箱的装箱添加此

borderRadius: BorderRadius.circular(radius),

相关内容

最新更新