LinearGauge constructor

LinearGauge({
  1. Key? key,
  2. double? start = 0,
  3. double? end = 100,
  4. double? steps = 0,
  5. @Deprecated('Use ValueBar instead') double? value = 0,
  6. GaugeOrientation? gaugeOrientation = GaugeOrientation.horizontal,
  7. bool? showLinearGaugeContainer = true,
  8. LinearGaugeBoxDecoration? linearGaugeBoxDecoration = const LinearGaugeBoxDecoration(),
  9. double? labelTopMargin = 0.0,
  10. required RulerStyle? rulers,
  11. List<RangeLinearGauge>? rangeLinearGauge = const [],
  12. List<CustomRulerLabel>? customLabels = const [],
  13. ValueBarPosition? valueBarPosition = ValueBarPosition.center,
  14. List<ValueBar>? valueBar = const [],
  15. List<BasePointer>? pointers = const [],
  16. bool enableGaugeAnimation = false,
  17. double? extendLinearGauge = 0,
  18. bool fillExtend = false,
  19. double animationGap = 0,
  20. int animationDuration = 1000,
  21. Curve animationType = Curves.ease,
  22. List<CustomCurve>? curves = const [],
})

LinearGauge is a visualization of measurement widget with a linear scale values. LinearGauge as rich sets of config parameters which can be modified as per requirement

start and end is responsible to paint the values as a label.

LinearGauge(
  steps: 2,
  start: 0,
  end: 100,
),

Implementation

LinearGauge({
  Key? key,
  this.start = 0,
  this.end = 100,
  this.steps = 0,
  @Deprecated('Use ValueBar instead') this.value = 0,
  this.gaugeOrientation = GaugeOrientation.horizontal,
  this.showLinearGaugeContainer = true,
  this.linearGaugeBoxDecoration = const LinearGaugeBoxDecoration(),
  this.labelTopMargin = 0.0,
  required this.rulers,
  this.rangeLinearGauge = const [],
  this.customLabels = const [],
  this.valueBarPosition = ValueBarPosition.center,
  this.valueBar = const [],
  this.pointers = const [],
  this.enableGaugeAnimation = false,
  this.extendLinearGauge = 0,
  this.fillExtend = false,
  this.animationGap = 0,
  this.animationDuration = 1000,
  this.animationType = Curves.ease,
  this.curves = const [],
})  : assert(() {
        if (customLabels!.isNotEmpty) {
          assert(customLabels.length >= 2,
              "At least two CustomRulerLabel should be added");

          assert((customLabels.first.value! < customLabels.last.value!),
              "Start should be less then end");
        }
        if (rulers != null) {
          if (gaugeOrientation == GaugeOrientation.horizontal) {
            if (rulers.rulerPosition == RulerPosition.bottom ||
                rulers.rulerPosition == RulerPosition.center ||
                rulers.rulerPosition == RulerPosition.top) {
              return true;
            } else {
              assert(
                  false,
                  'Invalid ruler position. Rulers must be horizontal,'
                  'positioned at top, bottom, or center.');
            }
          } else {
            if (rulers.rulerPosition == RulerPosition.right ||
                rulers.rulerPosition == RulerPosition.center ||
                rulers.rulerPosition == RulerPosition.left) {
              return true;
            } else {
              assert(
                  false,
                  'Invalid ruler position. Rulers must be vertical,'
                  'positioned at left, right, or center.');
            }
          }
        }
        return true;
      }()),
      super(key: key);