FormeSlider constructor

FormeSlider({
  1. double? initialValue,
  2. required String name,
  3. bool readOnly = false,
  4. required double min,
  5. required double max,
  6. Key? key,
  7. int? order,
  8. bool quietlyValidate = false,
  9. InputDecoration? decoration,
  10. FormeFieldDecorator<double>? decorator,
  11. SemanticFormatterCallback? semanticFormatterCallback,
  12. ValueChanged<double>? onChangeStart,
  13. ValueChanged<double>? onChangeEnd,
  14. ValueChanged<double>? onChanged,
  15. int? divisions,
  16. Color? activeColor,
  17. Color? inactiveColor,
  18. SliderThemeData? sliderThemeData,
  19. MouseCursor? mouseCursor,
  20. FormeLabelRender? labelRender,
  21. Duration? asyncValidatorDebounce,
  22. AutovalidateMode? autovalidateMode,
  23. FormeFieldStatusChanged<double>? onStatusChanged,
  24. dynamic onInitialed,
  25. FormeFieldSetter<double>? onSaved,
  26. FormeValidator<double>? validator,
  27. FormeAsyncValidator<double>? asyncValidator,
  28. bool registrable = true,
  29. bool enabled = true,
  30. dynamic valueUpdater,
  31. FormeFieldValidationFilter<double>? validationFilter,
  32. FocusNode? focusNode,
})

Implementation

FormeSlider({
  double? initialValue,
  required String name,
  bool readOnly = false,
  required this.min,
  required this.max,
  Key? key,
  int? order,
  bool quietlyValidate = false,

  /// used for [FormeInputDecorator], if you specific a [FormeFieldDecorator] , this will not work
  InputDecoration? decoration,
  FormeFieldDecorator<double>? decorator,
  SemanticFormatterCallback? semanticFormatterCallback,
  ValueChanged<double>? onChangeStart,
  ValueChanged<double>? onChangeEnd,
  ValueChanged<double>? onChanged,
  int? divisions,
  Color? activeColor,
  Color? inactiveColor,
  SliderThemeData? sliderThemeData,
  MouseCursor? mouseCursor,
  FormeLabelRender? labelRender,
  Duration? asyncValidatorDebounce,
  AutovalidateMode? autovalidateMode,
  FormeFieldStatusChanged<double>? onStatusChanged,
  FormeFieldInitialed<double>? onInitialed,
  FormeFieldSetter<double>? onSaved,
  FormeValidator<double>? validator,
  FormeAsyncValidator<double>? asyncValidator,
  bool registrable = true,
  bool enabled = true,
  FormeFieldValueUpdater<double>? valueUpdater,
  FormeFieldValidationFilter<double>? validationFilter,
  FocusNode? focusNode,
}) : super(
        focusNode: focusNode,
        validationFilter: validationFilter,
        valueUpdater: valueUpdater,
        enabled: enabled,
        registrable: registrable,
        order: order,
        quietlyValidate: quietlyValidate,
        asyncValidatorDebounce: asyncValidatorDebounce,
        autovalidateMode: autovalidateMode,
        onStatusChanged: onStatusChanged,
        onInitialed: onInitialed,
        onSaved: onSaved,
        validator: validator,
        asyncValidator: asyncValidator,
        key: key,
        readOnly: readOnly,
        name: name,
        initialValue: initialValue ?? min,
        decorator: decorator ??
            (decoration == null
                ? null
                : FormeInputDecoratorBuilder(decoration: decoration)),
        builder: (baseState) {
          final _FormeSliderState state = baseState as _FormeSliderState;
          final bool readOnly = state.readOnly;

          final Widget slider = ValueListenableBuilder<double?>(
            valueListenable: state.notifier,
            builder: (context, _value, child) {
              final String? sliderLabel =
                  labelRender == null ? null : labelRender(state.value);
              SliderThemeData _sliderThemeData =
                  sliderThemeData ?? SliderTheme.of(state.context);
              if (_sliderThemeData.thumbShape == null) {
                _sliderThemeData = _sliderThemeData.copyWith(
                    thumbShape: CustomSliderThumbCircle(value: state.value));
              }
              return SliderTheme(
                data: _sliderThemeData,
                child: Slider(
                  value: state.value,
                  min: min,
                  max: max,
                  focusNode: state.focusNode,
                  label: sliderLabel,
                  divisions: divisions ?? (max - min).floor(),
                  activeColor: activeColor,
                  inactiveColor: inactiveColor,
                  onChangeStart: (v) {
                    state.focusNode.requestFocus();
                    onChangeStart?.call(v);
                  },
                  onChangeEnd: (v) {
                    state.didChange(v);
                    onChangeEnd?.call(v);
                  },
                  semanticFormatterCallback: semanticFormatterCallback,
                  mouseCursor: mouseCursor,
                  onChanged: readOnly
                      ? null
                      : (double value) {
                          state.updateValue(value);
                          onChanged?.call(value);
                        },
                ),
              );
            },
          );

          return slider;
        },
      );