How to Draw a Solid Circle using Canvas in Flutter?

This Article is posted by seven.srikanth at 12-01-2019 18:03:07

In this article, I'm going to share you the code for creating a Circle using Canvas in Flutter as below.
You can add below call to your code and create a Circle in your program.
class DrawCircle extends CustomPainter {
Paint _paint;
DrawCircle() {
_paint = Paint()
..color = Colors.green
..strokeWidth = 10.0
..style = PaintingStyle.fill;
}
@override
void paint(Canvas canvas, Size size) {
canvas.drawCircle(Offset(0.0, 0.0), 100.0, _paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return false;
}
}
In order to create a Circle in your program, you can follow below example.
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Container(
child: CustomPaint(painter: DrawCircle()),
),
),
Hope this example will be useful to you.
Thanks,
Srikanth

Tags: How to Draw a Solid Circle using Canvas in Flutter?



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.



Recent Articles


How to deploy flutter web site on GitHub using peanut

Posted by nikhilchaudhary12155 on 13 Oct 2019 Article


AnimatedPositioned Widget Example in Flutter

Posted by seven.srikanth on 10 Oct 2019 Article


Flutter Open-Source and directory lists

Posted by nishantkotatech on 09 Oct 2019 Article


Flutter Travelling Couple Leading Page - Flutter Web Series 3

Posted by nikhilchaudhary12155 on 05 Oct 2019 Article



© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com