Skip to content

Instantly share code, notes, and snippets.

@PreyeaRegmi
Created June 15, 2021 09:26
Show Gist options
  • Save PreyeaRegmi/17d82d0162dcf73cc7eefaef74ba6f20 to your computer and use it in GitHub Desktop.
Save PreyeaRegmi/17d82d0162dcf73cc7eefaef74ba6f20 to your computer and use it in GitHub Desktop.
The paint method of "CurvePageSwitcher" to draw tab selection arc
//The paint method of "CurvePageSwitcher" to draw tab selection arc
void _drawSwipeAbleArc(Canvas canvas, Size size) {
Path path = Path();
path.moveTo(-2, size.height - archBottomOffset);
path.cubicTo(
-2,
size.height - archBottomOffset,
size.width / 2,
size.height - arcHeight - archBottomOffset,
size.width + 2,
size.height - archBottomOffset);
path.moveTo(size.width + 2, size.height - archBottomOffset);
path.close();
double left, right;
if (showLeftAsFirstPage) {
left = size.width / 2 - size.width / 2 * animation.value;
right = size.width / 2;
swipeArcPaint.color = Colors.green;
} else {
left = size.width / 2;
right = size.width * animation.value;
swipeArcPaint.color = Colors.deepPurple;
}
canvas.clipRect(Rect.fromLTRB(left, 0, right, size.height));
canvas.drawPath(path, swipeArcPaint);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment