-
-
Save MarcinusX/46e6dc77284d7c1e6f3d9d907ce8899d to your computer and use it in GitHub Desktop.
This file contains 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
class TicketCard extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return ClipPath( | |
clipper: TicketClipper(10.0), | |
child: Material( | |
elevation: 4.0, | |
shadowColor: Color(0x30E5E5E5), | |
color: Colors.transparent, | |
child: ClipPath( | |
clipper: TicketClipper(12.0), | |
child: Card( | |
elevation: 0.0, | |
margin: const EdgeInsets.all(2.0), | |
child: _buildCardContent(), | |
), | |
), | |
), | |
); | |
} | |
[...] | |
} | |
class TicketClipper extends CustomClipper<Path> { | |
final double radius; | |
TicketClipper(this.radius); | |
@override | |
Path getClip(Size size) { | |
var path = new Path(); | |
path.lineTo(0.0, size.height); | |
path.lineTo(size.width, size.height); | |
path.lineTo(size.width, 0.0); | |
path.addOval( | |
Rect.fromCircle(center: Offset(0.0, size.height / 2), radius: radius)); | |
path.addOval( | |
Rect.fromCircle(center: Offset(size.width, size.height / 2), radius: radius)); | |
return path; | |
} | |
@override | |
bool shouldReclip(CustomClipper<Path> oldClipper) => true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment