materialSliderBuilder function

Widget materialSliderBuilder(
  1. FormFieldState<double> field
)

The default FastSlider Material FormFieldBuilder.

Returns an InputDecorator that contains an expanded Slider.adaptive as the only child of a Row.

Implementation

Widget materialSliderBuilder(FormFieldState<double> field) {
  field as FastSliderState;
  final FastSliderState(:decoration, :didChange, :enabled, :value!, :widget) =
      field;

  final prefix = widget.prefixBuilder?.call(field);
  final suffix = widget.suffixBuilder?.call(field);

  final slider = Row(
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
      if (prefix is Widget) prefix,
      Expanded(
        child: Slider.adaptive(
          activeColor: widget.activeColor,
          allowedInteraction: widget.allowedInteraction,
          autofocus: widget.autofocus,
          divisions: widget.divisions,
          focusNode: field.focusNode,
          inactiveColor: widget.inactiveColor,
          label: widget.labelBuilder?.call(field),
          max: widget.max,
          min: widget.min,
          mouseCursor: widget.mouseCursor,
          onChangeEnd: widget.onChangeEnd,
          onChanged: enabled ? didChange : null,
          onChangeStart: widget.onChangeStart,
          overlayColor: widget.overlayColor,
          secondaryActiveColor: widget.secondaryActiveColor,
          secondaryTrackValue: widget.secondaryTrackValue,
          semanticFormatterCallback: widget.semanticFormatterCallback,
          thumbColor: widget.thumbColor,
          value: value,
        ),
      ),
      if (suffix is Widget) suffix,
    ],
  );

  if (widget.showInputDecoration) {
    return InputDecorator(
      decoration: decoration,
      child: slider,
    );
  }

  return slider;
}