diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c3650..8cebb59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,3 +30,9 @@ ## 1.0.3+3 - Change GitHub workflow badge routes + +## 1.1.0 + +- Modify the formula to get the radius of CircularSeekBar + +- Fix bug: Large barWidth with strokeCap round looks odd(#1) \ No newline at end of file diff --git a/README.md b/README.md index e6ed805..8eda13b 100644 --- a/README.md +++ b/README.md @@ -254,7 +254,7 @@ Add this to your package's `pubspec.yaml` file: ```yaml dependencies: - circular_seek_bar: ^1.0.3 + circular_seek_bar: ^1.1.0 ``` or diff --git a/lib/circular_seek_bar.dart b/lib/circular_seek_bar.dart index 279d78a..97ddc27 100644 --- a/lib/circular_seek_bar.dart +++ b/lib/circular_seek_bar.dart @@ -437,10 +437,11 @@ class _SeekBarPainter extends CustomPainter { final Offset center = Offset(size.width / 2, size.height / 2); final double largerThumbWidth = - barWidth >= (outerThumbRadius + (outerThumbStrokeWidth / 2)) - ? barWidth - : (outerThumbRadius + (outerThumbStrokeWidth / 2)); - final double radius = min(center.dx, center.dy) - largerThumbWidth; + (outerThumbRadius / 2 + outerThumbStrokeWidth / 2) >= (innerThumbRadius / 2 + innerThumbStrokeWidth / 2) + ? (outerThumbRadius / 2 + outerThumbStrokeWidth / 2) + : (innerThumbRadius / 2 + innerThumbStrokeWidth / 2); + final double seekBarMargin = largerThumbWidth >= (barWidth / 2) ? largerThumbWidth : barWidth / 2; + final double radius = min(center.dx, center.dy) - seekBarMargin; double realStartAngle = startAngle + angleOffset; double startAngleWithOffsetRadian = _degreesToRadians(realStartAngle); @@ -457,7 +458,7 @@ class _SeekBarPainter extends CustomPainter { endAngle: sweepAngleRadian, tileMode: TileMode.mirror, colors: trackGradientColors, - transform: GradientRotation(startAngleWithOffsetRadian - 0.1), + transform: GradientRotation(startAngleWithOffsetRadian - asin((barWidth / 2) / radius)), ); trackPaint.shader = trackGradient.createShader(rect); } @@ -469,7 +470,7 @@ class _SeekBarPainter extends CustomPainter { endAngle: sweepAngleRadian, tileMode: TileMode.mirror, colors: progressGradientColors, - transform: GradientRotation(startAngleWithOffsetRadian - 0.1), + transform: GradientRotation(startAngleWithOffsetRadian - asin((barWidth / 2) / radius)), ); progressPaint.shader = progressGradient.createShader(rect); diff --git a/pubspec.yaml b/pubspec.yaml index 0d145c9..b960067 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: circular_seek_bar description: Circular progress/seek bar package for flutter that supports customizable animations, dashes, and gradients. -version: 1.0.3+3 +version: 1.1.0 repository: https://github.com/seosh817/Flutter_CircularSeekBar environment: