Skip to content

Commit

Permalink
[Example] Enhance slider track shape.
Browse files Browse the repository at this point in the history
  • Loading branch information
xclud committed Dec 5, 2022
1 parent 9170abf commit 677255e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions example/lib/centered_slider_track_shape.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,22 @@ class CenteredRectangularSliderTrackShape extends RectangularSliderTrackShape {
}

final activeRect = Rect.fromLTRB(
thumbCenter.dx, trackRect.top, trackCenter.dx, trackRect.bottom);
thumbCenter.dx + thumbSize.width / 2,
trackRect.top,
trackRect.center.dx,
trackRect.bottom,
);
if (!activeRect.isEmpty) {
context.canvas.drawRect(activeRect, activePaint);
}

final Rect rightTrackSegment = Rect.fromLTRB(
min(trackCenter.dx, thumbCenter.dx - thumbSize.width / 2),
trackRect.top,
trackRect.right,
trackRect.bottom);
max(trackCenter.dx, thumbCenter.dx - thumbSize.width / 2),
trackRect.top,
trackRect.right,
trackRect.bottom,
);

if (!rightTrackSegment.isEmpty) {
context.canvas.drawRect(rightTrackSegment, inactivePaint);
}
Expand Down

0 comments on commit 677255e

Please sign in to comment.