GaugeTokens class

Immutable set of resolved design tokens consumed by every render engine.

GaugeTokens is the single source of truth for all visual properties used by the gauge painting layer. Every parameter is optional and ships with a sensible const default, so developers only need to supply the values they want to customise:

// Use all defaults:
const GaugeTokens()

// Override just the accent colour:
const GaugeTokens(valueColor: Color(0xFFE91E63))

The class is designed to be composed through copyWith and animated through lerp; the render engine has no knowledge of where the values came from.

Implementers

Constructors

GaugeTokens({Color trackColor = const Color(0xFF3D3D3D), double trackStrokeWidth = 8.0, StrokeCap trackStrokeCap = StrokeCap.round, double trackBorderRadius = 4.0, Color valueColor = const Color(0xFF6750A4), double valueStrokeWidth = 10.0, Gradient? valueGradient, double valueGlowRadius = 0.0, Color? valueGlowColor, Color needleColor = const Color(0xFF6750A4), double needleWidth = 3.0, NeedleTipStyle needleTipStyle = NeedleTipStyle.sharp, bool needleDropShadow = false, Color knobColor = const Color(0xFF6750A4), double knobRadius = 8.0, Color? knobBorderColor, double knobBorderWidth = 2.0, GaugeTickStyle majorTick = const GaugeTickStyle(color: Color(0xFF9E9E9E), strokeWidth: 1.5, length: 12), GaugeTickStyle minorTick = const GaugeTickStyle(color: Color(0xFFBDBDBD), strokeWidth: 1.0, length: 6), TextStyle labelStyle = const TextStyle(color: Color(0xFF9E9E9E), fontSize: 10), double labelOffset = 16.0, Color zoneNormal = const Color(0xFF0077BB), Color zoneWarning = const Color(0xFFEE7733), Color zoneDanger = const Color(0xFFCC3311), TextStyle annotationTextStyle = const TextStyle(color: Color(0xFF9E9E9E), fontSize: 10), Color dragOverlayColor = const Color(0x336750A4), double dragOverlayRadius = 20.0, Duration animationDuration = const Duration(milliseconds: 600), Curve animationCurve = Curves.easeInOut})
Creates a fully-resolved token set.
const

Properties

animationCurve Curve
Easing curve applied to the implicit value-change animation.
final
animationDuration Duration
Duration of the implicit value-change animation.
final
annotationTextStyle TextStyle
TextStyle used for freeform annotation labels painted onto the gauge face.
final
dragOverlayColor Color
Colour of the semi-transparent circular overlay shown at the drag contact point while the user is adjusting the gauge value.
final
dragOverlayRadius double
Radius of the drag overlay circle, in logical pixels.
final
hashCode int
The hash code for this object.
no setterinherited
knobBorderColor Color?
Optional colour of the ring drawn around the centre knob.
final
knobBorderWidth double
Stroke width of the optional knob border ring, in logical pixels.
final
knobColor Color
Fill colour of the centre knob.
final
knobRadius double
Radius of the centre knob circle, in logical pixels.
final
labelOffset double
Radial distance between the outer tick edge and the nearest label edge, in logical pixels.
final
labelStyle TextStyle
TextStyle used for the numeric scale labels around the gauge.
final
majorTick GaugeTickStyle
Style applied to major (primary) tick marks.
final
minorTick GaugeTickStyle
Style applied to minor (secondary) tick marks.
final
needleColor Color
Colour of the needle body.
final
needleDropShadow bool
Whether the needle casts a drop shadow.
final
needleTipStyle NeedleTipStyle
Shape drawn at the tip of the needle.
final
needleWidth double
Width of the needle at its widest point, in logical pixels.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
trackBorderRadius double
Corner radius used when the gauge renders a linear / bar track.
final
trackColor Color
Background track colour.
final
trackStrokeCap StrokeCap
Cap style applied to both ends of the background track arc.
final
trackStrokeWidth double
Stroke width of the background track arc, in logical pixels.
final
valueColor Color
Solid fill colour of the value indicator arc.
final
valueGlowColor Color?
Colour of the outer glow. Falls back to valueColor at 50 % opacity when null and valueGlowRadius is positive.
final
valueGlowRadius double
Blur radius of the outer glow painted behind the value arc or bar.
final
valueGradient Gradient?
Optional gradient applied along the value indicator arc.
final
valueStrokeWidth double
Stroke width of the value indicator arc, in logical pixels.
final
zoneDanger Color
Colour used for the "danger / critical" zone arc segment.
final
zoneNormal Color
Colour used for the "normal / safe" zone arc segment.
final
zoneWarning Color
Colour used for the "warning / caution" zone arc segment.
final

Methods

copyWith({Color? trackColor, double? trackStrokeWidth, StrokeCap? trackStrokeCap, double? trackBorderRadius, Color? valueColor, double? valueStrokeWidth, Gradient? valueGradient, double? valueGlowRadius, Color? valueGlowColor, Color? needleColor, double? needleWidth, NeedleTipStyle? needleTipStyle, bool? needleDropShadow, Color? knobColor, double? knobRadius, Color? knobBorderColor, double? knobBorderWidth, GaugeTickStyle? majorTick, GaugeTickStyle? minorTick, TextStyle? labelStyle, double? labelOffset, Color? zoneNormal, Color? zoneWarning, Color? zoneDanger, TextStyle? annotationTextStyle, Color? dragOverlayColor, double? dragOverlayRadius, Duration? animationDuration, Curve? animationCurve}) GaugeTokens
Returns a copy of this token set with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

lerp(GaugeTokens a, GaugeTokens b, double t) GaugeTokens
Linearly interpolates between two GaugeTokens instances.