I have to hide the thumb on Slider widget. I set thumb colour to transparent with SliderTheme widget. It does not work. How to hide thumb?
I set thumb colour to transparent.
Center(
child: SliderTheme(
child: Slider(
value: 50,
max: 100,
min: 0,
activeColor: Colors.black,
inactiveColor: Colors.grey,
onChanged: (double value) {},
),
data: SliderTheme.of(context).copyWith(
trackHeight: 28,
thumbColor: Colors.transparent,
thumbShape: null),
),
)
I expect the slider widget without thumb.
Bit of a workaround but you can set the thumbShape
to have a radius of 0:
Center(
child: SliderTheme(
child: Slider(
value: 50,
max: 100,
min: 0,
activeColor: Colors.black,
inactiveColor: Colors.grey,
onChanged: (double value) {},
),
data: SliderTheme.of(context).copyWith(
trackHeight: 28,
thumbColor: Colors.transparent,
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 0.0)),
),
),
Not a workaround. The correct way to do it.
Set the thumbShape
to SliderComponentShape.noThumb
i.e.
SliderTheme.of(context).copyWith(
trackHeight: 28,
thumbShape: SliderComponentShape.noThumb,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With