FormBuilderRangeSlider constructor

FormBuilderRangeSlider({
  1. Key? key,
  2. required String name,
  3. FormFieldValidator<RangeValues>? validator,
  4. RangeValues? initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<RangeValues?>? onChanged,
  7. ValueTransformer<RangeValues?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<RangeValues>? onSaved,
  10. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. required double min,
  14. required double max,
  15. int? divisions,
  16. Color? activeColor,
  17. Color? inactiveColor,
  18. ValueChanged<RangeValues>? onChangeStart,
  19. ValueChanged<RangeValues>? onChangeEnd,
  20. RangeLabels? labels,
  21. SemanticFormatterCallback? semanticFormatterCallback,
  22. dynamic displayValues = DisplayValues.all,
  23. TextStyle? minTextStyle,
  24. TextStyle? textStyle,
  25. TextStyle? maxTextStyle,
  26. NumberFormat? numberFormat,
})

Creates field to select a range of values on a Slider

Implementation

FormBuilderRangeSlider({
  Key? key,
  //From Super
  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 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,
}) : super(
          key: key,
          initialValue: initialValue,
          name: name,
          validator: validator,
          valueTransformer: valueTransformer,
          onChanged: onChanged,
          autovalidateMode: autovalidateMode,
          onSaved: onSaved,
          enabled: enabled,
          onReset: onReset,
          decoration: decoration,
          focusNode: focusNode,
          builder: (FormFieldState<RangeValues?> field) {
            final state = field as _FormBuilderRangeSliderState;
            final _numberFormat = numberFormat ?? NumberFormat.compact();

            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) {
                              state.requestFocus();
                              field.didChange(values);
                            }
                          : null,
                    ),
                    Row(
                      children: <Widget>[
                        if (displayValues != DisplayValues.none &&
                            displayValues != DisplayValues.current)
                          Text(
                            _numberFormat.format(min),
                            style: minTextStyle ?? textStyle,
                          ),
                        const Spacer(),
                        if (displayValues != DisplayValues.none &&
                            displayValues != DisplayValues.minMax)
                          Text(
                            '${_numberFormat.format(field.value!.start)} - ${_numberFormat.format(field.value!.end)}',
                            style: textStyle,
                          ),
                        const Spacer(),
                        if (displayValues != DisplayValues.none &&
                            displayValues != DisplayValues.current)
                          Text(
                            _numberFormat.format(max),
                            style: maxTextStyle ?? textStyle,
                          ),
                      ],
                    ),
                  ],
                ),
              ),
            );
          });