flutter - 防止 BoxShadow 被父级裁剪
问题描述
我正在用盒子阴影构建我自己的类似材质的卡片。我想将其中的几个组合在一起PageView
,这样我就可以在卡片之间滑动——每张卡片都Card
应该填满屏幕的整个宽度。卡片具有BoxShadow
as 装饰,但是当将 插入Card
(PageView
或任何其他包装小部件)时,它会在被的边界框BoxShadow
夹住时消失。PageView
这可以通过将 包装Card
成 a来解决Padding
,但这不是我想要的,因为我更喜欢由最外面的小部件为整个视图的所有子小部件提供填充 - 这样以防我的填充发生变化我没有更改每个小部件。
这就是我的Card
代码的样子:
class Card extends StatelessWidget {
final Widget child;
final EdgeInsetsGeometry padding;
Card({@required this.child, this.padding});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(color: Colors.white, boxShadow: <BoxShadow>[
BoxShadow(color: Color.fromRGBO(0, 0, 0, 0.1), blurRadius: 14.0),
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.1),
offset: Offset(0, 2),
blurRadius: 2.0)
]),
child: Padding(
padding: padding ?? EdgeInsets.all(20),
child: this.child,
),
);
}
}
包装其中的几个会导致所描述的剪辑行为。
有没有办法告诉 Flutter 不要剪掉任何从边界框“泄漏”出来的东西? 当将小部件放置在弹跳的堆栈上时,也会发生相同的行为。
解决方案
推荐阅读
- java - 调试 SPOJ STPAR 的 java 代码
- spring - Spring中RestController和Controller的作用域
- python - Django CreateView 多对象插入
- swift - 尝试进行涉及 web 视图的 UI 测试时 Xcode 崩溃
- c# - 表名和实体框架6的关系是怎么做的?
- javascript - 如何使用 Cypress io 将功能文件与步骤定义链接起来
- c# - 如何将一串 0 和 1 转换为布尔数组
- python - 当我输入时,它说无效选项
- python - 使用 Python Bottle 生成物品不起作用
- c++ - boost::filesystem::create_directory 抛出了 boost::filesystem::filesystem_error: Bad address