FormBuilderSlider constructor

FormBuilderSlider({
  1. Key? key,
  2. required String name,
  3. FormFieldValidator<double>? validator,
  4. required double initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<double?>? onChanged,
  7. ValueTransformer<double?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<double>? onSaved,
  10. AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. String? restorationId,
  14. FormFieldErrorBuilder? errorBuilder,
  15. required double min,
  16. required double max,
  17. int? divisions,
  18. Color? activeColor,
  19. Color? inactiveColor,
  20. ValueChanged<double>? onChangeStart,
  21. ValueChanged<double>? onChangeEnd,
  22. String? label,
  23. SemanticFormatterCallback? semanticFormatterCallback,
  24. NumberFormat? numberFormat,
  25. DisplayValues displayValues = DisplayValues.all,
  26. bool autofocus = false,
  27. MouseCursor? mouseCursor,
  28. Widget maxValueWidget(
    1. String max
    )?,
  29. Widget minValueWidget(
    1. String min
    )?,
  30. Widget valueWidget(
    1. String value
    )?,
})

Creates field for selection of a numerical value on a slider

Implementation

FormBuilderSlider({
  super.key,
  required super.name,
  super.validator,
  required double super.initialValue,
  super.decoration,
  super.onChanged,
  super.valueTransformer,
  super.enabled,
  super.onSaved,
  super.autovalidateMode = AutovalidateMode.disabled,
  super.onReset,
  super.focusNode,
  super.restorationId,
  super.errorBuilder,
  required this.min,
  required this.max,
  this.divisions,
  this.activeColor,
  this.inactiveColor,
  this.onChangeStart,
  this.onChangeEnd,
  this.label,
  this.semanticFormatterCallback,
  this.numberFormat,
  this.displayValues = DisplayValues.all,
  this.autofocus = false,
  this.mouseCursor,
  this.maxValueWidget,
  this.minValueWidget,
  this.valueWidget,
}) : super(
       builder: (FormFieldState<double?> field) {
         final state = field as _FormBuilderSliderState;
         final effectiveNumberFormat = numberFormat ?? NumberFormat.compact();

         return InputDecorator(
           decoration: state.decoration,
           child: Container(
             padding: const EdgeInsets.only(top: 10.0),
             child: Column(
               crossAxisAlignment: CrossAxisAlignment.start,
               children: [
                 Slider(
                   value: field.value!,
                   min: min,
                   max: max,
                   divisions: divisions,
                   activeColor: activeColor,
                   inactiveColor: inactiveColor,
                   onChangeEnd: onChangeEnd,
                   onChangeStart: onChangeStart,
                   label: label,
                   semanticFormatterCallback: semanticFormatterCallback,
                   onChanged: state.enabled
                       ? (value) {
                           field.didChange(value);
                         }
                       : null,
                   autofocus: autofocus,
                   mouseCursor: mouseCursor,
                   focusNode: state.effectiveFocusNode,
                 ),
                 Row(
                   children: <Widget>[
                     if (displayValues != DisplayValues.none &&
                         displayValues != DisplayValues.current)
                       minValueWidget?.call(
                             effectiveNumberFormat.format(min),
                           ) ??
                           Text(effectiveNumberFormat.format(min)),
                     const Spacer(),
                     if (displayValues != DisplayValues.none &&
                         displayValues != DisplayValues.minMax)
                       valueWidget?.call(
                             effectiveNumberFormat.format(field.value),
                           ) ??
                           Text(effectiveNumberFormat.format(field.value)),
                     const Spacer(),
                     if (displayValues != DisplayValues.none &&
                         displayValues != DisplayValues.current)
                       maxValueWidget?.call(
                             effectiveNumberFormat.format(max),
                           ) ??
                           Text(effectiveNumberFormat.format(max)),
                   ],
                 ),
               ],
             ),
           ),
         );
       },
     );