FormeCupertinoSlider constructor

FormeCupertinoSlider({
  1. required String name,
  2. required double min,
  3. required double max,
  4. int? divisions,
  5. double? initialValue,
  6. bool readOnly = false,
  7. Key? key,
  8. int? order,
  9. ValueChanged<double>? onChangeStart,
  10. ValueChanged<double>? onChangeEnd,
  11. ValueChanged<double>? onChanged,
  12. Color? activeColor,
  13. Color thumbColor = CupertinoColors.white,
  14. bool quietlyValidate = false,
  15. Duration? asyncValidatorDebounce,
  16. AutovalidateMode? autovalidateMode,
  17. FormeValueChanged<double>? onValueChanged,
  18. FormeFocusChanged<double>? onFocusChanged,
  19. FormeFieldValidationChanged<double>? onValidationChanged,
  20. FormeFieldInitialed<double>? onInitialed,
  21. FormeFieldSetter<double>? onSaved,
  22. FormeValidator<double>? validator,
  23. FormeAsyncValidator<double>? asyncValidator,
  24. FormeFieldDecorator<double>? decorator,
  25. bool registrable = true,
  26. bool enabled = true,
})

Implementation

FormeCupertinoSlider({
  required String name,
  required this.min,
  required this.max,
  int? divisions,
  double? initialValue,
  bool readOnly = false,
  Key? key,
  int? order,
  ValueChanged<double>? onChangeStart,
  ValueChanged<double>? onChangeEnd,
  ValueChanged<double>? onChanged,
  Color? activeColor,
  Color thumbColor = CupertinoColors.white,
  bool quietlyValidate = false,
  Duration? asyncValidatorDebounce,
  AutovalidateMode? autovalidateMode,
  FormeValueChanged<double>? onValueChanged,
  FormeFocusChanged<double>? onFocusChanged,
  FormeFieldValidationChanged<double>? onValidationChanged,
  FormeFieldInitialed<double>? onInitialed,
  FormeFieldSetter<double>? onSaved,
  FormeValidator<double>? validator,
  FormeAsyncValidator<double>? asyncValidator,
  FormeFieldDecorator<double>? decorator,
  bool registrable = true,
  bool enabled = true,
}) : super(
        enabled: enabled,
        registrable: registrable,
        order: order,
        decorator: decorator,
        key: key,
        readOnly: readOnly,
        name: name,
        initialValue: initialValue ?? min,
        quietlyValidate: quietlyValidate,
        asyncValidatorDebounce: asyncValidatorDebounce,
        autovalidateMode: autovalidateMode,
        onValueChanged: onValueChanged,
        onFocusChanged: onFocusChanged,
        onValidationChanged: onValidationChanged,
        onInitialed: onInitialed,
        onSaved: onSaved,
        validator: validator,
        asyncValidator: asyncValidator,
        builder: (baseState) {
          final _FormeCupertinoSliderState state =
              baseState as _FormeCupertinoSliderState;
          return ValueListenableBuilder<double?>(
              valueListenable: state.notifier,
              builder: (context, _value, child) {
                return Focus(
                  focusNode: state.focusNode,
                  child: CupertinoSlider(
                      value: state.value,
                      min: min,
                      max: max,
                      onChangeStart: (v) {
                        state.focusNode.requestFocus();
                        onChangeStart?.call(v);
                      },
                      onChangeEnd: (v) {
                        state.didChange(v);
                        onChangeEnd?.call(v);
                      },
                      activeColor: activeColor,
                      thumbColor: thumbColor,
                      divisions: divisions ?? (max - min).floor(),
                      onChanged: state.readOnly
                          ? null
                          : (v) {
                              state.updateValue(v);
                              onChanged?.call(v);
                            }),
                );
              });
        },
      );