FormBuilderRangeSlider constructor
FormBuilderRangeSlider({
- Key? key,
- required String name,
- FormFieldValidator<
RangeValues> ? validator, - RangeValues? initialValue,
- InputDecoration decoration = const InputDecoration(),
- ValueChanged<
RangeValues?> ? onChanged, - ValueTransformer<
RangeValues?> ? valueTransformer, - bool enabled = true,
- FormFieldSetter<
RangeValues> ? onSaved, - AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
- VoidCallback? onReset,
- FocusNode? focusNode,
- required double min,
- required double max,
- int? divisions,
- Color? activeColor,
- Color? inactiveColor,
- ValueChanged<
RangeValues> ? onChangeStart, - ValueChanged<
RangeValues> ? onChangeEnd, - RangeLabels? labels,
- SemanticFormatterCallback? semanticFormatterCallback,
- DisplayValues displayValues = DisplayValues.all,
- TextStyle? minTextStyle,
- TextStyle? textStyle,
- TextStyle? maxTextStyle,
- NumberFormat? numberFormat,
- bool shouldRequestFocus = false,
Creates field to select a range of values on a Slider
Implementation
FormBuilderRangeSlider({
super.key,
required super.name,
super.validator,
super.initialValue,
super.decoration,
super.onChanged,
super.valueTransformer,
super.enabled,
super.onSaved,
super.autovalidateMode = AutovalidateMode.disabled,
super.onReset,
super.focusNode,
required this.min,
required this.max,
this.divisions,
this.activeColor,
this.inactiveColor,
this.onChangeStart,
this.onChangeEnd,
this.labels,
this.semanticFormatterCallback,
this.displayValues = DisplayValues.all,
this.minTextStyle,
this.textStyle,
this.maxTextStyle,
this.numberFormat,
this.shouldRequestFocus = false,
}) : super(builder: (FormFieldState<RangeValues?> field) {
final state = field as _FormBuilderRangeSliderState;
final effectiveNumberFormat = numberFormat ?? NumberFormat.compact();
if (initialValue == null) {
field.setValue(RangeValues(min, min));
}
return InputDecorator(
decoration: state.decoration,
child: Container(
padding: const EdgeInsets.only(top: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RangeSlider(
values: field.value!,
min: min,
max: max,
divisions: divisions,
activeColor: activeColor,
inactiveColor: inactiveColor,
onChangeEnd: onChangeEnd,
onChangeStart: onChangeStart,
labels: labels,
semanticFormatterCallback: semanticFormatterCallback,
onChanged: state.enabled
? (values) {
if (shouldRequestFocus) {
state.requestFocus();
}
field.didChange(values);
}
: null,
),
Row(
children: <Widget>[
if (displayValues != DisplayValues.none &&
displayValues != DisplayValues.current)
Text(
effectiveNumberFormat.format(min),
style: minTextStyle ?? textStyle,
),
const Spacer(),
if (displayValues != DisplayValues.none &&
displayValues != DisplayValues.minMax)
Text(
'${effectiveNumberFormat.format(field.value!.start)} - ${effectiveNumberFormat.format(field.value!.end)}',
style: textStyle,
),
const Spacer(),
if (displayValues != DisplayValues.none &&
displayValues != DisplayValues.current)
Text(
effectiveNumberFormat.format(max),
style: maxTextStyle ?? textStyle,
),
],
),
],
),
),
);
});