Instantly share code, notes, and snippets.

Embed
What would you like to do?
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