How to create a age range slider in flutter?

后端 未结 5 2045
清酒与你
清酒与你 2021-01-20 02:29

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

5条回答
  •  终归单人心
    2021-01-20 03:13

    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.

提交回复
热议问题