@@ -39,6 +39,25 @@ const ColorRGBA kSliderDefaultInactiveTrackColor = ColorRGBA(
3939/// Default opacity of slider's overlay.
4040const double kSliderDefaultOverlayOpacity = 0.12 ;
4141
42+ /// The shape of a slider's thumb.
43+ enum SliderThumbShapeEnum {
44+ /// A circle of [SliderProperties.thumbRadius] .
45+ circle,
46+
47+ /// A [SliderProperties.thumbWidth] × [SliderProperties.thumbHeight]
48+ /// rounded rectangle, like a fader knob.
49+ rectangle,
50+ }
51+
52+ /// How a slider draws the marks at its divisions.
53+ enum SliderTickMarkStyle {
54+ /// Dots on the track.
55+ dot,
56+
57+ /// Short lines below the track, longer at every fifth mark.
58+ notch,
59+ }
60+
4261/// Slider is a widget that lets the user select a value from a given range.
4362/// Refer to [Slider] (https://api.flutter.dev/flutter/material/Slider-class.html)
4463/// in Flutter for more details.
@@ -50,6 +69,11 @@ class SliderNode extends SceneNode with CustomPropertiesMixin {
5069 /// Currently selected value of slider.
5170 double value;
5271
72+ /// Where a thin marker sits on the track, e.g. the current reading next
73+ /// to an alarm limit the slider sets. No marker when null. Bindable as
74+ /// `markerValue` .
75+ double ? markerValue;
76+
5377 /// Holds configurable properties of the slider.
5478 @override
5579 covariant SliderProperties properties;
@@ -79,6 +103,7 @@ class SliderNode extends SceneNode with CustomPropertiesMixin {
79103 required super .name,
80104 required super .basicBoxLocal,
81105 required this .value,
106+ this .markerValue,
82107 super .outerBoxLocal,
83108 super .retainedOuterBoxLocal,
84109 super .visible,
@@ -114,12 +139,17 @@ class SliderNode extends SceneNode with CustomPropertiesMixin {
114139 };
115140
116141 @override
117- List <TriggerType > get triggerTypes => [TriggerType .changed];
142+ List <TriggerType > get triggerTypes => [
143+ TriggerType .changed,
144+ TriggerType .changeEnd,
145+ ];
118146
119147 @override
120148 late final List <ValueModel > propertyVariables = [
121149 ...super .propertyVariables,
122150 DoubleValue (name: 'value' , value: value),
151+ DoubleValue (name: 'markerValue' , value: markerValue ?? 0 ),
152+ ColorValue (name: 'activeTrackColor' , value: properties.activeTrackColor),
123153 ];
124154
125155 /// Creates a [SliderNode] instance from a JSON object.
@@ -224,6 +254,56 @@ class SliderProperties extends CustomProperties with FieldsHolder {
224254 /// room for the thumb's overlay. Mirrors `Slider.padding` .
225255 EdgeInsetsModel ? padding;
226256
257+ /// The thumb's shape.
258+ SliderThumbShapeEnum thumbShape;
259+
260+ /// Width of a rectangle thumb.
261+ double thumbWidth;
262+
263+ /// Height of a rectangle thumb.
264+ double thumbHeight;
265+
266+ /// Corner radius of a rectangle thumb.
267+ double thumbCornerRadius;
268+
269+ /// Border drawn around the thumb. Transparent for none.
270+ ColorRGBA thumbBorderColor;
271+
272+ /// Width of [thumbBorderColor] .
273+ double thumbBorderWidth;
274+
275+ /// Color of a short grip line across a rectangle thumb. Transparent for
276+ /// none.
277+ ColorRGBA thumbGripColor;
278+
279+ /// Whether the active track runs from the thumb to the end instead of
280+ /// from the start to the thumb, e.g. to shade the "above the limit" zone.
281+ bool fillFromEnd;
282+
283+ /// How division marks are drawn.
284+ SliderTickMarkStyle tickMarkStyle;
285+
286+ /// Draw a notch only at every this many divisions, e.g. 2 for a notch
287+ /// every 10% on a slider that snaps every 5%. Every fifth notch drawn is a
288+ /// long one.
289+ int notchEvery;
290+
291+ /// Color of the [SliderNode.markerValue] marker.
292+ ColorRGBA markerColor;
293+
294+ /// Width of the marker.
295+ double markerWidth;
296+
297+ /// Height of the marker, centered on the track.
298+ double markerHeight;
299+
300+ /// The lowest value the thumb can be dragged to, when the track's range
301+ /// ([min] to [max] ) is wider than what may be picked. Null for [min] .
302+ double ? selectableMin;
303+
304+ /// The highest value the thumb can be dragged to. Null for [max] .
305+ double ? selectableMax;
306+
227307 /// Creates a [SliderProperties] instance with the given data.
228308 SliderProperties ({
229309 this .activeTrackColor = ColorRGBA .black,
@@ -255,6 +335,21 @@ class SliderProperties extends CustomProperties with FieldsHolder {
255335 this .secondaryTrackValue,
256336 this .secondaryActiveTrackColor,
257337 this .padding,
338+ this .thumbShape = SliderThumbShapeEnum .circle,
339+ this .thumbWidth = 14 ,
340+ this .thumbHeight = 24 ,
341+ this .thumbCornerRadius = 2 ,
342+ this .thumbBorderColor = ColorRGBA .transparent,
343+ this .thumbBorderWidth = 2 ,
344+ this .thumbGripColor = ColorRGBA .transparent,
345+ this .fillFromEnd = false ,
346+ this .tickMarkStyle = SliderTickMarkStyle .dot,
347+ this .notchEvery = 1 ,
348+ this .markerColor = ColorRGBA .white,
349+ this .markerWidth = 2 ,
350+ this .markerHeight = 14 ,
351+ this .selectableMin,
352+ this .selectableMax,
258353 });
259354
260355 /// Duplicates this [SliderProperties] instance with the given data
@@ -289,6 +384,21 @@ class SliderProperties extends CustomProperties with FieldsHolder {
289384 double ? secondaryTrackValue,
290385 ColorRGBA ? secondaryActiveTrackColor,
291386 EdgeInsetsModel ? padding,
387+ SliderThumbShapeEnum ? thumbShape,
388+ double ? thumbWidth,
389+ double ? thumbHeight,
390+ double ? thumbCornerRadius,
391+ ColorRGBA ? thumbBorderColor,
392+ double ? thumbBorderWidth,
393+ ColorRGBA ? thumbGripColor,
394+ bool ? fillFromEnd,
395+ SliderTickMarkStyle ? tickMarkStyle,
396+ int ? notchEvery,
397+ ColorRGBA ? markerColor,
398+ double ? markerWidth,
399+ double ? markerHeight,
400+ double ? selectableMin,
401+ double ? selectableMax,
292402 }) {
293403 return SliderProperties (
294404 activeTrackColor: activeTrackColor ?? this .activeTrackColor,
@@ -326,6 +436,21 @@ class SliderProperties extends CustomProperties with FieldsHolder {
326436 secondaryActiveTrackColor:
327437 secondaryActiveTrackColor ?? this .secondaryActiveTrackColor,
328438 padding: padding ?? this .padding,
439+ thumbShape: thumbShape ?? this .thumbShape,
440+ thumbWidth: thumbWidth ?? this .thumbWidth,
441+ thumbHeight: thumbHeight ?? this .thumbHeight,
442+ thumbCornerRadius: thumbCornerRadius ?? this .thumbCornerRadius,
443+ thumbBorderColor: thumbBorderColor ?? this .thumbBorderColor,
444+ thumbBorderWidth: thumbBorderWidth ?? this .thumbBorderWidth,
445+ thumbGripColor: thumbGripColor ?? this .thumbGripColor,
446+ fillFromEnd: fillFromEnd ?? this .fillFromEnd,
447+ tickMarkStyle: tickMarkStyle ?? this .tickMarkStyle,
448+ notchEvery: notchEvery ?? this .notchEvery,
449+ markerColor: markerColor ?? this .markerColor,
450+ markerWidth: markerWidth ?? this .markerWidth,
451+ markerHeight: markerHeight ?? this .markerHeight,
452+ selectableMin: selectableMin ?? this .selectableMin,
453+ selectableMax: selectableMax ?? this .selectableMax,
329454 );
330455 }
331456
@@ -561,6 +686,21 @@ class SliderProperties extends CustomProperties with FieldsHolder {
561686 secondaryTrackValue,
562687 secondaryActiveTrackColor,
563688 padding,
689+ thumbShape,
690+ thumbWidth,
691+ thumbHeight,
692+ thumbCornerRadius,
693+ thumbBorderColor,
694+ thumbBorderWidth,
695+ thumbGripColor,
696+ fillFromEnd,
697+ tickMarkStyle,
698+ notchEvery,
699+ markerColor,
700+ markerWidth,
701+ markerHeight,
702+ selectableMin,
703+ selectableMax,
564704 ];
565705
566706 /// Creates a [SliderProperties] instance from a JSON object.
0 commit comments