Want to clip overflow inside a BoxDecoration? There is a ClipOval class that can be used like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
class ClipExample extends StatelessWidget { @override Widget build(BuildContext context) { return new Scaffold( backgroundColor: Colors.blueAccent, body: new Center( child: new CircleAvatar( backgroundColor: Colors.amberAccent, child: new ClipOval( clipper:new MyClipper(), child: new Container( color: Colors.red, height: 10.0, ), ), ), ), ); } } class MyClipper extends CustomClipper<Rect>{ @override Rect getClip(Size size) { return new Rect.fromCircle(center: new Offset(0.0,0.0), radius: 50.0 ); } @override bool shouldReclip(CustomClipper<Rect> oldClipper) { return false; } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.