Skip to content

Commit

Permalink
Merge pull request #271 from Afroz-Shaikh/fix/assert-valuebar-value
Browse files Browse the repository at this point in the history
[BUG-FIX] Assert Error when ValueBar value is less than CustomRulerLable value
  • Loading branch information
geekruchika authored May 20, 2024
2 parents cb271e7 + 221f6c6 commit 0f902d9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 12 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyVerticalGauge(),
home: LinearGaugeExample(),
),
);
}
Expand All @@ -23,6 +23,7 @@ class LinearGaugeExample extends StatefulWidget {
}

class _LinearGaugeExampleState extends State<LinearGaugeExample> {
double value = 20;
@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -33,6 +34,16 @@ class _LinearGaugeExampleState extends State<LinearGaugeExample> {
rulers: RulerStyle(
rulerPosition: RulerPosition.bottom,
),
valueBar: [
ValueBar(
value: 20,
offset: 300,
)
],
customLabels: [
CustomRulerLabel(text: "Hello One", value: value),
CustomRulerLabel(text: "Hello Two", value: 60),
],
pointers: const [
Pointer(
value: 50,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.3"
version: "1.0.4"
leak_tracker:
dependency: transitive
description:
Expand Down
6 changes: 6 additions & 0 deletions lib/src/linear_gauge/linear_gauge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class LinearGauge extends StatefulWidget {
this.curves = const [],
}) : assert(() {
if (customLabels!.isNotEmpty) {
if (valueBar != []) {
assert(
valueBar!.every(
(element) => element.value >= customLabels.first.value!),
"Valuebar value should be greater than or equal to customLabels start value");
}
assert(customLabels.length >= 2,
"At least two CustomRulerLabel should be added");

Expand Down

0 comments on commit 0f902d9

Please sign in to comment.