From 89214f2d89bb4ddb286fca29153b608646b97c40 Mon Sep 17 00:00:00 2001 From: SahilSharma2710 Date: Mon, 20 Mar 2023 19:17:34 +0530 Subject: [PATCH 1/2] assert added for custumm labels --- lib/linear_gauge/linear_gauge.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/linear_gauge/linear_gauge.dart b/lib/linear_gauge/linear_gauge.dart index 17a74800..1d8702d5 100644 --- a/lib/linear_gauge/linear_gauge.dart +++ b/lib/linear_gauge/linear_gauge.dart @@ -39,6 +39,15 @@ class LinearGauge extends StatefulWidget { this.enableAnimation = false, this.extendLinearGauge = 0, }) : assert(() { + if (customLabels!.isNotEmpty) { + if (customLabels.length < 2) { + assert(false, "At least two CustomRulerLabel should be added"); + } + + if (customLabels.first.value! > customLabels.last.value!) { + assert(false, "Start should be less then end"); + } + } if (rulers != null) { if (gaugeOrientation == GaugeOrientation.horizontal) { if (rulers.rulerPosition == RulerPosition.bottom || From 749c3000e314d41ddd95a3ac9725ca767c85ac74 Mon Sep 17 00:00:00 2001 From: SahilSharma2710 Date: Tue, 21 Mar 2023 11:36:49 +0530 Subject: [PATCH 2/2] assert updated --- lib/linear_gauge/linear_gauge.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/linear_gauge/linear_gauge.dart b/lib/linear_gauge/linear_gauge.dart index 1d8702d5..67d3ad5f 100644 --- a/lib/linear_gauge/linear_gauge.dart +++ b/lib/linear_gauge/linear_gauge.dart @@ -40,13 +40,11 @@ class LinearGauge extends StatefulWidget { this.extendLinearGauge = 0, }) : assert(() { if (customLabels!.isNotEmpty) { - if (customLabels.length < 2) { - assert(false, "At least two CustomRulerLabel should be added"); - } + assert(customLabels.length >= 2, + "At least two CustomRulerLabel should be added"); - if (customLabels.first.value! > customLabels.last.value!) { - assert(false, "Start should be less then end"); - } + assert((customLabels.first.value! < customLabels.last.value!), + "Start should be less then end"); } if (rulers != null) { if (gaugeOrientation == GaugeOrientation.horizontal) {