Complete the code to create a rounded rectangle clip with a radius of 10.
ClipRRect( borderRadius: BorderRadius.circular([1]), child: Container(color: Colors.blue, width: 100, height: 100), )
The BorderRadius.circular method takes a radius value. Here, 10 creates a smooth rounded corner.
Complete the code to clip a widget with a circular shape using ClipPath.
ClipPath( clipper: CircleClipper(), child: Container(color: Colors.red, width: 100, height: 100), ); class CircleClipper extends CustomClipper<Path> { @override Path getClip(Size size) { return Path()..addOval(Rect.fromCircle(center: Offset(size.width / 2, size.height / 2), radius: [1])); } @override bool shouldReclip(CustomClipper<Path> oldClipper) => false; }
The radius for a circle clip should be half the width to fit perfectly inside the widget.
Fix the error in the ClipRRect code to properly clip the child widget.
ClipRRect( borderRadius: BorderRadius.circular(20), child: [1](color: Colors.green, width: 150, height: 150), )
The child of ClipRRect should be a widget that can have size and color, like Container. Text or layout widgets alone won't show the clipping effect clearly.
Fill both blanks to create a ClipPath that clips a triangle shape.
ClipPath( clipper: [1](), child: Container(color: Colors.orange, width: 120, height: 120), ); class [2] extends CustomClipper<Path> { @override Path getClip(Size size) { Path path = Path(); path.moveTo(size.width / 2, 0); path.lineTo(0, size.height); path.lineTo(size.width, size.height); path.close(); return path; } @override bool shouldReclip(CustomClipper<Path> oldClipper) => false; }
The clipper class and its instance must have the same name. Here, TriangleClipper defines the triangle shape.
Fill all three blanks to create a ClipRRect with elliptical border radius on top corners only.
ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.[1](x: 30, y: 50),
topRight: Radius.[2](x: [3], y: 50),
),
child: Container(color: Colors.purple, width: 200, height: 100),
)Use Radius.elliptical to create elliptical corners. The x and y values define the ellipse radii. Here, top corners have elliptical radius with x=30 and x=40 respectively.