Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize the drag circle #76

Open
itMcdull opened this issue Oct 10, 2024 · 2 comments
Open

How to customize the drag circle #76

itMcdull opened this issue Oct 10, 2024 · 2 comments

Comments

@itMcdull
Copy link

expected
image
How should I do it?

@suragch
Copy link
Owner

suragch commented Oct 10, 2024

Currently there is no way to do that with this package. It would take reworking the thumb as a Widget rather than a plain circle. You'll need to build a custom widget for your use case.

I'll leave this issue open, though, because having a thumb widget would be useful to add in the future.

@itMcdull
Copy link
Author

  void _drawThumb(Canvas canvas, Size localSize) {
    final thumbPaint = Paint()..color = thumbColor;
    final barCapRadius = _barHeight / 2;
    final availableWidth = localSize.width - _barHeight;
    var thumbDx = _thumbValue * availableWidth + barCapRadius;
    if (!_thumbCanPaintOutsideBar) {
      thumbDx = thumbDx.clamp(barCapRadius, localSize.width - barCapRadius);
    }
    final rect = Rect.fromCenter(
      center: Offset(thumbDx, localSize.height / 2),
      width: 2,
      height: 40,
    );
    canvas.drawRect(
      rect,
      thumbPaint..style = PaintingStyle.fill,
    );
    // Draw the blue circles at the top and bottom of the vertical line
    final circlePaint = Paint()
      ..color = thumbColor
      ..style = PaintingStyle.fill;
    canvas.drawCircle(
      Offset(thumbDx, barCapRadius + 28),
      barCapRadius,
      circlePaint,
    );
    canvas.drawCircle(
      Offset(thumbDx, localSize.height - 28),
      barCapRadius,
      circlePaint,
    );
  }

Modify _drawThumb to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants