dart - 剪裁后材料标高不起作用
问题描述
Material
将小部件elevation
包装到ClipPath
.
剪裁前。
剪裁后。
任何人都知道为什么会这样?
这是我的代码。
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: ClipPath(
clipper: MyCustomClipper(),
child: Material(
child: SizedBox(height: 100.0, width: 100.0),
color: Colors.lightBlue,
elevation: 8.0,
),
),
),
),
);
}
}
class MyCustomClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
double x = size.width;
double y = size.height;
Path path = Path()
..lineTo(0, y)
..lineTo(x, y - 20.0)
..lineTo(x, 0)
..lineTo(0, 0)
..close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}
解决方案
推荐阅读
- python-3.x - 余额利息功能
- c++ - 模板流运算符重载错误:与 basic_istream 和 basic_ifstream 之间的差异有关的无效引用初始化
- objective-c - 如何运行 dispatch_group?
- javascript - 如何修复未捕获的类型错误:无法读取 null 的属性“addEventListener”(与脚本文件的位置无关......我认为)
- r - 循环遍历表列表并写入 R 中的 csv
- python - Cython“内存高效双向链表”
- c - 使用指针时的意外行为和编译器错误
- python - 如何使用 python 将所有函数和单个函数作为运行时参数执行
- bash - 从 Bash 的 for 循环中写入文件
- c# - 如何使用iText7 c#从pdf中提取图像