Skip to content

Commit

Permalink
Merge branch 'master' into HEAD
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	example/pubspec.yaml
#	pubspec.yaml
  • Loading branch information
alr2413 committed Nov 12, 2022
1 parent 8000d3d commit 2dddae5
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# 1.0.2
* Added value precision to knob controller
* updated dependencies

# 1.0.1
* Added show minor tick labels parameter
* updated dependencies

# 1.0.0

* Initial release.
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class _MyHomePageState extends State<MyHomePage> {
maximum: _maximum,
startAngle: 0,
endAngle: 180,
precision: 2,
);
_controller.addOnValueChangedListener(valueChangedListener);
}
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
version: 1.0.0+2

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -27,7 +27,7 @@ dependencies:

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.4
cupertino_icons: ^1.0.5

knob_widget:
path: ../
Expand Down
8 changes: 8 additions & 0 deletions lib/src/controller/knob_controller.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:math' as math;
import 'dart:math';

import 'package:flutter/widgets.dart';
import 'package:knob_widget/src/helper/angle_helper.dart';
Expand Down Expand Up @@ -29,6 +30,9 @@ class KnobController extends ValueNotifier<KnobValue> {
/// end angle of knob in degree
final double endAngle;

/// precision of value
final int precision;

/// Constructs a [KnobController]
///
KnobController({
Expand All @@ -37,6 +41,7 @@ class KnobController extends ValueNotifier<KnobValue> {
this.maximum = 100,
this.startAngle = 0,
this.endAngle = 180,
this.precision = 2,
}) : assert(maximum > minimum,
'Maximum value must be greater than minimum value.'),
assert(maximum >= initial && initial >= minimum,
Expand Down Expand Up @@ -64,6 +69,9 @@ class KnobController extends ValueNotifier<KnobValue> {
/// make sure the value is between the provided min & max
///
void setCurrentValue(double newValue) {
num mod = pow(10.0, precision);
newValue = ((newValue * mod).round().toDouble() / mod);
//
if (newValue < value.minimum || newValue > value.maximum) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/control_knob_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ControlKnobContainer extends StatefulWidget {
}) : super(key: key);

@override
_ControlKnobContainerState createState() => _ControlKnobContainerState();
State<ControlKnobContainer> createState() => _ControlKnobContainerState();
}

class _ControlKnobContainerState extends State<ControlKnobContainer> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/knob_gesture_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class KnobGestureDetector extends StatefulWidget {
}) : super(key: key);

@override
_KnobGestureDetectorState createState() => _KnobGestureDetectorState();
State<KnobGestureDetector> createState() => _KnobGestureDetectorState();
}

class _KnobGestureDetectorState extends State<KnobGestureDetector> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/radial_drag_gesture_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RadialDragGestureDetector extends StatefulWidget {
}) : super(key: key);

@override
_RadialDragGestureDetectorState createState() =>
State<RadialDragGestureDetector> createState() =>
_RadialDragGestureDetectorState();
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: knob_widget
description: A knob widget for flutter
version: 1.0.1
version: 1.0.2
homepage: https://github.com/alr2413/knob_widget

environment:
Expand All @@ -11,7 +11,7 @@ dependencies:
flutter:
sdk: flutter

provider: ^6.0.3
provider: ^6.0.4

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 2dddae5

Please sign in to comment.