Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a age range slider in flutter?

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 that has two input fieldss

like image 468
russsell phillips Avatar asked Nov 29 '22 21:11

russsell phillips


2 Answers

As I also needed this widget for one of my developments, I decided to develop it.

Here is the outcome

enter image description here

Source code my be found on GitHub

Full explanation on this link

like image 57
boeledi Avatar answered Dec 05 '22 19:12

boeledi


What you are looking for is the Slider widget. I think a discrete slider would work best for what you are trying to achieve.

You should take a look at the Flutter Gallery App which has examples of many widgets along with source code which can be found on their GitHub repo.

Looking at their code from their Slider Demo, I have found this example which may suit your need:

new Slider(
                  value: _discreteValue,
                  min: 0.0,
                  max: 100.0,
                  divisions: 5,
                  label: '${_discreteValue.round()}',
                  onChanged: (double value) {
                    setState(() {
                      _discreteValue = value;
                    });
                  },
                ),
                const Text('Discrete'),
              ],
            )

Of course you will need to adjust this code to better suit your needs, but hopefully it gets you started in the right direction.

Let me know if you have any questions!

like image 37
Mans Avatar answered Dec 05 '22 20:12

Mans