FormeSlider constructor
FormeSlider({
- Key? key,
- String? name,
- double? initialValue,
- FormeAsyncValidator<
double> ? asyncValidator, - Duration? asyncValidatorDebounce,
- AutovalidateMode? autovalidateMode,
- bool enabled = true,
- FocusNode? focusNode,
- FormeFieldInitialized<
double> ? onInitialized, - FormeFieldSetter<
double> ? onSaved, - FormeFieldStatusChanged<
double> ? onStatusChanged, - int? order,
- bool quietlyValidate = false,
- bool readOnly = false,
- bool requestFocusOnUserInteraction = true,
- FormeFieldValidationFilter<
double> ? validationFilter, - FormeValidator<
double> ? validator, - FormeFieldDecorator<
double> ? decorator, - required double min,
- required double max,
- Color? activeColor,
- bool autofocus = false,
- int? divisions,
- Color? inactiveColor,
- FormeLabelRender? labelRender,
- MouseCursor? mouseCursor,
- ValueChanged<
double> ? onChangeEnd, - ValueChanged<
double> ? onChangeStart, - ValueChanged<
double> ? onChanged, - MaterialStateProperty<
Color?> ? overlayColor, - Color? secondaryActiveColor,
- double? secondaryTrackValue,
- SemanticFormatterCallback? semanticFormatterCallback,
- SliderThemeData? sliderThemeData,
- Color? thumbColor,
- InputDecoration? decoration,
- SliderComponentShapeBuilder? shapeBuilder,
Implementation
FormeSlider({
super.key,
super.name,
double? initialValue,
super.asyncValidator,
super.asyncValidatorDebounce,
super.autovalidateMode,
super.enabled = true,
super.focusNode,
super.onInitialized,
super.onSaved,
super.onStatusChanged,
super.order,
super.quietlyValidate = false,
super.readOnly = false,
super.requestFocusOnUserInteraction = true,
super.validationFilter,
super.validator,
FormeFieldDecorator<double>? decorator,
required this.min,
required this.max,
this.activeColor,
this.autofocus = false,
this.divisions,
this.inactiveColor,
this.labelRender,
this.mouseCursor,
this.onChangeEnd,
this.onChangeStart,
this.onChanged,
this.overlayColor,
this.secondaryActiveColor,
this.secondaryTrackValue,
this.semanticFormatterCallback,
this.sliderThemeData,
this.thumbColor,
this.decoration,
this.shapeBuilder,
}) : super.allFields(
initialValue: initialValue ?? min,
decorator: decorator ??
(decoration == null
? null
: FormeInputDecorationDecorator(
decorationBuilder: (context) => 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 themeData =
sliderThemeData ?? SliderTheme.of(state.context);
if (themeData.thumbShape == null) {
themeData = themeData.copyWith(
thumbShape:
shapeBuilder?.call(state.context, state.value) ??
CustomSliderThumbCircle(value: state.value));
}
return SliderTheme(
data: themeData,
child: Slider(
secondaryTrackValue: secondaryTrackValue,
secondaryActiveColor: secondaryActiveColor,
autofocus: autofocus,
overlayColor: overlayColor,
thumbColor: thumbColor,
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;
},
);