0

I have tried using cubicTo and conicTo and other curves on CustomPainter canvas but the generated are not smooth to make it look like simple closed curve.

2
  • Can you please share the code what you tried and what exactly you want to achieve? Commented Sep 30, 2019 at 4:23
  • can you please also share an image what you want to achieve Commented Sep 30, 2019 at 5:01

1 Answer 1

1

You can extend CustomPainter class to make shapes, lines and curves.

Keep in mind that, start point of any path is x=0, y=0 (Top Left Corner).

When you want to draw closed paths then you have to always close path after you completed your drawing with path. See below example, it will draw smooth wave shape.

You can check here what and how you can draw with path

class CustomWave extends CustomPainter {

  @override
  void paint(Canvas canvas, Size size) {

    var path = Path();
    var paint = Paint();

    path.moveTo(0,size.height*0.84);
    path.quadraticBezierTo(size.width*0.25, size.height*0.77, size.width*0.52, size.height*0.84);
    path.quadraticBezierTo(size.width*0.74, size.height*0.92, size.width, size.height*0.84);
    path.lineTo(size.width, size.height);
    path.lineTo(0, size.height);
    path.close();
    paint.color = AppColors.primaryColor.withOpacity(0.70);
    canvas.drawPath(path, paint);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => true; 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.