Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active June 25, 2019 03:44
Show Gist options
  • Save duytq94/c22e19d4d987a131f0af0f3672633d56 to your computer and use it in GitHub Desktop.
Save duytq94/c22e19d4d987a131f0af0f3672633d56 to your computer and use it in GitHub Desktop.
class TabIndicatorPainter extends CustomPainter {
Paint painter;
double xPos, radiusOval;
double radiusOvalOrigin = 20.0;
TabIndicatorPainter(double xPos, double radiusOval) {
painter = new Paint()
..color = Colors.white
..style = PaintingStyle.fill;
this.xPos = xPos;
this.radiusOval = radiusOval;
}
double processRadiusOval(double value) {
if (value <= 30.0) {
return value;
} else if (value <= 40.0) {
return value = radiusOvalOrigin + (40.0 - value);
} else if (value <= 45) {
return value = radiusOvalOrigin + (value - 40.0);
} else {
return value = radiusOvalOrigin + (50.0 - value);
}
}
double processRadiusOval2(double value) {
if (value <= 40.0) {
return 0.0;
} else if (value <= 45.0) {
return value = value - 40.0;
} else {
return value = (50.0 - value);
}
}
@override
void paint(Canvas canvas, Size size) {
canvas.drawOval(
new Rect.fromLTRB(xPos - processRadiusOval2(radiusOval), 0.0, xPos + processRadiusOval(radiusOval), 20.0),
painter);
}
@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