Skip to content

Instantly share code, notes, and snippets.

@braulio94
Created January 10, 2019 23:41
Show Gist options
  • Save braulio94/c491668d0fa1225c3f7ce9593d0747a7 to your computer and use it in GitHub Desktop.
Save braulio94/c491668d0fa1225c3f7ce9593d0747a7 to your computer and use it in GitHub Desktop.
class ClippedCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipPath(
clipper: CardClipper(35.0),
child: Container(
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topRight: Radius.circular(60.0), topLeft: Radius.circular(60.0))
),
height: 100.0,
),
);
}
}
class CardClipper extends CustomClipper<Path> {
final double radius;
CardClipper(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(size.width / 2, 0.0), radius: radius));
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}
@braulio94
Copy link
Author

Clipped Card Example

49787286_399921580781104_5222889701785993216_n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment