ReactiveSlider constructor
ReactiveSlider({
- Key? key,
- String? formControlName,
- FormControl<
num> ? formControl, - double min = 0.0,
- double max = 1.0,
- int? divisions,
- ReactiveSliderLabelBuilder? labelBuilder,
- Color? activeColor,
- Color? inactiveColor,
- Color? thumbColor,
- SemanticFormatterCallback? semanticFormatterCallback,
- bool autofocus = false,
- MouseCursor? mouseCursor,
- FocusNode? focusNode,
- EdgeInsetsGeometry? padding,
- SliderInteraction? allowedInteraction,
- ReactiveFormFieldCallback<
num> ? onChangeEnd, - ReactiveFormFieldCallback<
num> ? onChangeStart, - ReactiveFormFieldCallback<
num> ? onChanged, - double? secondaryTrackValue,
- Color? secondaryActiveColor,
- WidgetStateProperty<
Color?> ? overlayColor,
Creates an instance os a ReactiveSlider.
Can optionally provide a formControl to bind this widget to a control.
Can optionally provide a formControlName to bind this ReactiveFormField
to a FormControl.
Must provide one of the arguments formControl or a formControlName,
but not both at the same time.
The labelBuilder is called each time the FormControl changes its value
so you can supply a label to the Slider.
Implementation
ReactiveSlider({
super.key,
super.formControlName,
super.formControl,
double min = 0.0,
double max = 1.0,
int? divisions,
ReactiveSliderLabelBuilder? labelBuilder,
Color? activeColor,
Color? inactiveColor,
Color? thumbColor,
SemanticFormatterCallback? semanticFormatterCallback,
bool autofocus = false,
MouseCursor? mouseCursor,
super.focusNode,
EdgeInsetsGeometry? padding,
SliderInteraction? allowedInteraction,
ReactiveFormFieldCallback<num>? onChangeEnd,
ReactiveFormFieldCallback<num>? onChangeStart,
ReactiveFormFieldCallback<num>? onChanged,
double? secondaryTrackValue,
Color? secondaryActiveColor,
WidgetStateProperty<Color?>? overlayColor,
}) : super(
builder: (field) {
var value = field.value;
if (value == null) {
value = min;
} else if (value < min) {
value = min;
} else if (value > max) {
value = max;
}
return Slider(
value: value,
min: min,
max: max,
divisions: divisions,
secondaryTrackValue: secondaryTrackValue,
secondaryActiveColor: secondaryActiveColor,
overlayColor: overlayColor,
label:
labelBuilder != null ? labelBuilder(field.value ?? min) : null,
activeColor: activeColor,
inactiveColor: inactiveColor,
thumbColor: thumbColor,
semanticFormatterCallback: semanticFormatterCallback,
mouseCursor: mouseCursor,
autofocus: autofocus,
focusNode: field.focusNode,
padding: padding,
allowedInteraction: allowedInteraction,
onChangeEnd:
onChangeEnd != null ? (_) => onChangeEnd(field.control) : null,
onChangeStart:
onChangeStart != null
? (_) => onChangeStart(field.control)
: null,
onChanged:
field.control.enabled
? (value) {
field.didChange(value);
onChanged?.call(field.control);
}
: null,
);
},
);