Created
January 10, 2019 23:41
-
-
Save braulio94/c491668d0fa1225c3f7ce9593d0747a7 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
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; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clipped Card Example