Home > database >  How to create this rounded offset rectangle in flutter
How to create this rounded offset rectangle in flutter

Time:06-04

I am trying to create this shape but am struggling. Have tried using shape maker but am struggling also to make this shape. I also tried using path, but am unsure whether this will work.

Any suggestions?

what I am trying to achieve

CodePudding user response:

Here's a reference video, https://www.youtube.com/watch?v=AnKgtKxRLX4 I've used this few times and it worked pretty well

CodePudding user response:

With the help of CustomPainter we can draw any kind of custom button and container, Flutter gives you access to low-level graphics painting. Best of all, painting in Flutter is fast and efficient.

CustomPaint takes a painter argument of type CustomPainter, an abstract class from the Flutter APIs.

Container(
  color: Colors.yellow,
  child: CustomPaint(painter: FaceOutlinePainter()),
),

and in FaceOutlinePainter() class you can add the size , width , height and all other requirment.

class FaceOutlinePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    // TODO: draw something with canvas
  }

  @override
  bool shouldRepaint(FaceOutlinePainter oldDelegate) => false;
}
  • Related