Material
widget's elevation
not working after wrapping it into ClipPath
.
Before clipping.
After clipping.
Anyone knows why this is happening?
Here is my code.
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;
}