LinearGauge class

A powerful and customizable linear gauge widget.

This widget displays a linear gauge with extensive customization options including orientation, ruler styles, pointers, value bars, ranges, custom curves, animations, and interactivity.

Example usage:

LinearGauge(
  value: 0.65,
  orientation: LinearGaugeOrientation.horizontal,
  rulerStyle: RulerStyle.graduated,
  pointer: PointerConfig(
    style: PointerStyle.triangle,
    color: Colors.red,
  ),
  showValueBar: true,
  ranges: [
    LinearGaugeRange(start: 0.0, end: 0.3, color: Colors.green),
    LinearGaugeRange(start: 0.3, end: 0.7, color: Colors.yellow),
    LinearGaugeRange(start: 0.7, end: 1.0, color: Colors.red),
  ],
  animation: true,
  interactive: true,
  onValueChanged: (value) => print('Value: $value'),
)
Inheritance

Constructors

LinearGauge({Key? key, double value = 0.0, LinearGaugeOrientation orientation = LinearGaugeOrientation.horizontal, double? length, double thickness = 20.0, Color backgroundColor = const Color(0xFFE0E0E0), Color valueColor = Colors.blue, Gradient? valueGradient, RulerStyle rulerStyle = RulerStyle.none, RulerPosition rulerPosition = RulerPosition.start, int majorTickCount = 11, int minorTicksPerMajor = 4, double majorTickLength = 15.0, double minorTickLength = 8.0, Color tickColor = Colors.black54, double tickWidth = 1.5, TextStyle? labelStyle, String labelFormatter(double value)?, PointerConfig? pointer, bool showValueBar = true, BorderRadius? borderRadius, List<LinearGaugeRange>? ranges, bool showRangesBehind = true, Path customCurve(Size size)?, bool animation = false, Duration animationDuration = const Duration(milliseconds: 500), Curve animationCurve = Curves.easeInOut, bool interactive = false, OnLinearGaugeValueChanged? onValueChanged, VoidCallback? onInteractionStart, VoidCallback? onInteractionEnd, double minValue = 0, double maxValue = 100, bool showMinMaxLabels = false, bool showValueLabel = false, TextStyle? valueTextStyle, PointerPosition valueLabelPosition = PointerPosition.start, Widget? customPointerWidget, EdgeInsets padding = EdgeInsets.zero})
Creates a linear gauge widget.
const

Properties

animation → bool
Whether to animate value changes.
final
animationCurve → Curve
The curve for the animation.
final
animationDuration → Duration
The duration of the animation.
final
backgroundColor → Color
The background color of the gauge track.
final
borderRadius → BorderRadius?
The border radius of the gauge track and value bar.
final
customCurve → Path Function(Size size)?
Optional custom curve path for the gauge.
final
customPointerWidget → Widget?
Custom widget to display as pointer.
final
hashCode → int
The hash code for this object.
no setterinherited
interactive → bool
Whether the gauge is interactive (draggable/tappable).
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
labelFormatter → String Function(double value)?
Custom label formatter function.
final
labelStyle → TextStyle?
Text style for tick labels.
final
length → double?
The length of the gauge (width for horizontal, height for vertical).
final
majorTickCount → int
Number of major tick marks.
final
majorTickLength → double
The length of major tick marks.
final
maxValue → double
The maximum value (for label display).
final
minorTickLength → double
The length of minor tick marks.
final
minorTicksPerMajor → int
Number of minor ticks between major ticks.
final
minValue → double
The minimum value (for label display).
final
onInteractionEnd → VoidCallback?
Callback when interaction ends.
final
onInteractionStart → VoidCallback?
Callback when interaction starts.
final
onValueChanged → OnLinearGaugeValueChanged?
Callback when value changes during interaction.
final
orientation → LinearGaugeOrientation
The orientation of the gauge.
final
padding → EdgeInsets
Padding around the gauge.
final
pointer → PointerConfig?
The pointer configuration.
final
ranges → List<LinearGaugeRange>?
The ranges for the gauge.
final
rulerPosition → RulerPosition
The position of the ruler.
final
rulerStyle → RulerStyle
The style of the ruler/tick marks.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showMinMaxLabels → bool
Whether to show min/max labels.
final
showRangesBehind → bool
Whether to show ranges behind the value bar.
final
showValueBar → bool
Whether to show the value bar.
final
showValueLabel → bool
Whether to show the current value label.
final
thickness → double
The thickness of the gauge track.
final
tickColor → Color
The color of tick marks.
final
tickWidth → double
The width of tick marks.
final
value → double
The current value between 0.0 and 1.0.
final
valueColor → Color
The color of the value bar.
final
valueGradient → Gradient?
Optional gradient for the value bar.
final
valueLabelPosition → PointerPosition
Position of the value label.
final
valueTextStyle → TextStyle?
Text style for the value label.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<LinearGauge>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited