FormeCupertinoSlider constructor
FormeCupertinoSlider({
- required String name,
- required double min,
- required double 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,
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);
}),
);
});
},
);