FormBuilderSlider constructor
FormBuilderSlider({
- Key? key,
- required String name,
- FormFieldValidator<
double> ? validator, - required double initialValue,
- InputDecoration decoration = const InputDecoration(),
- ValueChanged<
double?> ? onChanged, - ValueTransformer<
double?> ? valueTransformer, - bool enabled = true,
- FormFieldSetter<
double> ? onSaved, - AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
- VoidCallback? onReset,
- FocusNode? focusNode,
- String? restorationId,
- FormFieldErrorBuilder? errorBuilder,
- required double min,
- required double max,
- int? divisions,
- Color? activeColor,
- Color? inactiveColor,
- ValueChanged<
double> ? onChangeStart, - ValueChanged<
double> ? onChangeEnd, - String? label,
- SemanticFormatterCallback? semanticFormatterCallback,
- NumberFormat? numberFormat,
- DisplayValues displayValues = DisplayValues.all,
- bool autofocus = false,
- MouseCursor? mouseCursor,
- Widget maxValueWidget(
- String max
- Widget minValueWidget(
- String min
- Widget valueWidget(
- 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)),
],
),
],
),
),
);
},
);