Scalars and everything else
The base class is concrete, so a slider, a stepper or a date holds its value in a plain AdvancedFieldController.
AdvancedFieldController<T, E> is not abstract. Construct it directly for any value with no dedicated controller and
bind it like any other field. Slider works in doubles and the field in ints, so the widget adapts both ways.
Source2 files
class _SliderInput extends StatelessWidget {
const _SliderInput({
required this.field,
required this.label,
required this.max,
});
final AdvancedFieldController<int, String> field;
final String label;
final int max;
@override
Widget build(BuildContext context) {
return AdvancedFieldBuilder<int, String>(
field: field,
builder: (context, state, _) {
final setter = field.getValueSetter();
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: InputDecorator(
decoration: InputDecoration(
labelText: '$label: ${state.value}',
errorText: state.error,
contentPadding: EdgeInsets.zero,
),
child: Slider(
value: state.value.toDouble(),
max: max.toDouble(),
divisions: max,
onChanged: setter == null ? null : (v) => setter(v.round()),
),
),
);
},
);
}
}DocsActions is a shorthand these docs define, not part of the package. See Rendering fields for the widget code an app writes.The same shape serves a stepper, a rating bar, a date picker or a colour swatch: hold the value in
AdvancedFieldController<T, E>, write it with setValue, and give it a validator like any other field. Ordinary user
writes need no force: — that is only for writing to a field you have marked read-only.
A widget that opens a picker instead of editing inline should also tell the field when the interaction ends, so
ValidationMode.onUnfocus can react — see Focus.