我有一个如下的用户界面(img1),当我滚动用户界面时,渐变卡会稍微重叠其父容器,但如果我删除渐变,一切都会正常。有没有办法在不删除卡片中的渐变背景的情况下防止这种重叠?
图片1:
图片2:
以下是我的示例代码:
Container(
margin: smallWidgetPadding,
width: MediaQuery.of(context).size.width,
decoration: ShapeDecoration(
color: colorScheme.onPrimary,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
shadows: [BoxShadow(color: colorScheme.shadow, blurRadius: 5)]),
child: Card(
margin: margin,
child: Container(
decoration: ShapeDecoration(
gradient: gradient, shape: roundedRectangleBorderless),
child: child)))
将
clipBehavior: Clip.antiAlias
设置在外部Container
。
Container(
clipBehavior: Clip.antiAlias,
// ...
)