Last active
January 13, 2025 17:00
-
-
Save coman3/e631fd55cd9cdf9bd4efe8ecfdbb85a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
@immutable | |
class ClipShadowPath extends StatelessWidget { | |
final Shadow shadow; | |
final CustomClipper<Path> clipper; | |
final Widget child; | |
ClipShadowPath({ | |
@required this.shadow, | |
@required this.clipper, | |
@required this.child, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
return CustomPaint( | |
painter: _ClipShadowShadowPainter( | |
clipper: this.clipper, | |
shadow: this.shadow, | |
), | |
child: ClipPath(child: child, clipper: this.clipper), | |
); | |
} | |
} | |
class _ClipShadowShadowPainter extends CustomPainter { | |
final Shadow shadow; | |
final CustomClipper<Path> clipper; | |
_ClipShadowShadowPainter({@required this.shadow, @required this.clipper}); | |
@override | |
void paint(Canvas canvas, Size size) { | |
var paint = shadow.toPaint(); | |
var clipPath = clipper.getClip(size).shift(shadow.offset); | |
canvas.drawPath(clipPath, paint); | |
} | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry if this wasted ya time, I've removed it :)