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;
}