Slider<D> constructor
- SelectionTrigger? eventTrigger,
- SymbolRenderer? handleRenderer,
- dynamic initialDomainValue,
- String? roleId,
- SliderListenerCallback? onChangeCallback,
- bool snapToDatum = false,
- SliderStyle? style,
- int layoutPaintOrder = common.LayoutViewPaintOrder.slider,
Constructs a Slider.
eventTrigger
sets the type of gesture handled by the slider.
handleRenderer
draws a handle for the slider. Defaults to a rectangle.
initialDomainValue
sets the initial position of the slider in domain
units. The default is the center of the chart.
onChangeCallback
will be called when the position of the slider
changes during a drag event.
snapToDatum
configures the slider to snap snap onto the nearest datum
(by domain distance) when dragged. By default, the slider can be
positioned anywhere along the domain axis.
style
configures the color and sizing of the slider line and handle.
layoutPaintOrder
configures the order in which the behavior should be
painted. This value should be relative to LayoutPaintViewOrder.slider.
(e.g. LayoutViewPaintOrder.slider + 1).
Implementation
factory Slider({
common.SelectionTrigger? eventTrigger,
common.SymbolRenderer? handleRenderer,
initialDomainValue,
String? roleId,
common.SliderListenerCallback? onChangeCallback,
bool snapToDatum = false,
common.SliderStyle? style,
int layoutPaintOrder = common.LayoutViewPaintOrder.slider,
}) {
eventTrigger ??= common.SelectionTrigger.tapAndDrag;
handleRenderer ??= common.RectSymbolRenderer();
// Default the handle size large enough to tap on a mobile device.
style ??=
common.SliderStyle(handleSize: const Rectangle<int>(0, 0, 20, 30));
return Slider._internal(
eventTrigger: eventTrigger,
handleRenderer: handleRenderer,
initialDomainValue: initialDomainValue,
onChangeCallback: onChangeCallback,
roleId: roleId,
snapToDatum: snapToDatum,
style: style,
desiredGestures: Slider._getDesiredGestures(eventTrigger),
layoutPaintOrder: layoutPaintOrder,
);
}