Search code examples
flutterslidersyncfusion

Syncfusion cutom widget onchanged parameter doesnot take void Function onPressed


I am trying to create a custom vertical slider with 4 in a row and I am using Syncfusion package, however, when I create a customer widget, onchanged parameter does not accept the Function variable when passed.

SfSliderTheme(
  data: SfSliderThemeData(
    thumbColor: Colors.blue[200],
    activeTrackHeight: kactive_slider_height,
    inactiveTrackHeight: kinactive_slider_height,
    activeTrackColor: kactive_slider_track_color,
    inactiveTrackColor: Colors.black,
    trackCornerRadius: -1.0,
  ),
  child: SfSlider.vertical(
    min: 0.0,
    max: 100.0,
    value: value,
    onChanged: (value) {},
  ),
),

This is my code and I am using multiple times, I want to create a custom widget but onChanged: does not take void Function onPressed. Is there a way?


Solution

  • While interacting with the slider, we will get the new value in the onChanged method. So that we can update the slider thumb with the new value. The new value is the type of dynamic, because the slider supports numeric and date time types.

    double value = 50.0;
    SfSlider.vertical(
        min: 0.0,
        max: 100.0,
        value: value,
        onChanged: (dynamic newValue) {
            setState(() {
               value = newValue;
            });
       },
    )