Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created September 3, 2018 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcinusX/46e6dc77284d7c1e6f3d9d907ce8899d to your computer and use it in GitHub Desktop.
Save MarcinusX/46e6dc77284d7c1e6f3d9d907ce8899d to your computer and use it in GitHub Desktop.
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