Created
June 29, 2019 09:13
-
-
Save NishantDesai1306/32a9d61dd7930c33d94bd560093df8b4 to your computer and use it in GitHub Desktop.
code for custom painter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyPainter extends CustomPainter { | |
final Offset center; | |
final double radius, containerHeight; | |
final BuildContext context; | |
Color color; | |
double statusBarHeight, screenWidth; | |
MyPainter({this.context, this.containerHeight, this.center, this.radius}) { | |
ThemeData theme = Theme.of(context); | |
color = theme.primaryColor; | |
statusBarHeight = MediaQuery.of(context).padding.top; | |
screenWidth = MediaQuery.of(context).size.width; | |
} | |
@override | |
void paint(Canvas canvas, Size size) { | |
Paint circlePainter = Paint(); | |
circlePainter.color = color; | |
canvas.clipRect(Rect.fromLTWH(0, 0, screenWidth, containerHeight + statusBarHeight)); | |
canvas.drawCircle(center, radius, circlePainter); | |
} | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment