Would anyone know how to create an age range slider in flutter? A slider which will have two input values. Somewhat like what Tinder has to choose min and max age. a slider
Thanks to boeledi This is a nice library for you.
RangeSlider(
min: minPrice,
max: maxPrice,
lowerValue: _lowerValue,
upperValue: _upperValue,
divisions: 50,
showValueIndicator: true,
valueIndicatorMaxDecimals: 4,
onChanged: (double newLowerValue, double newUpperValue) {
setState(() {
_lowerValue = newLowerValue;
_upperValue = newUpperValue;
});
},
onChangeStart: (double startLowerValue, double startUpperValue) {
print('Started with values: $startLowerValue and $startUpperValue');
},
onChangeEnd: (double newLowerValue, double newUpperValue) {
print('Ended with values: $newLowerValue and $newUpperValue');
},
)
Put it in your widget tree.
min is minimum value.
max is maximum value that you want.
Give lowerValue
and upperValue
initial global value, So when range changes this values will change too.
divisions = n
divide amount between lowerValue
and upperValue
to n section.
You have new values in onChanged
method.
Good luck.