From 677255ee3de6654961af1afea908e6dc9d993e29 Mon Sep 17 00:00:00 2001 From: "Mahdi K. Fard" Date: Mon, 5 Dec 2022 22:40:12 +0330 Subject: [PATCH] [Example] Enhance slider track shape. --- example/lib/centered_slider_track_shape.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/example/lib/centered_slider_track_shape.dart b/example/lib/centered_slider_track_shape.dart index c8905b6..c19f887 100644 --- a/example/lib/centered_slider_track_shape.dart +++ b/example/lib/centered_slider_track_shape.dart @@ -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); }