boeledi / RangeSlider

RangeSlider Widget for Flutter
Other
374 stars 67 forks source link

Cannot move any slider #1

Closed AlexandreRoba closed 6 years ago

AlexandreRoba commented 6 years ago

Hi,

I'm trying to use the range slider but I can't seem to move any of the thumb.

This is the code I have dropped on a widget:

RangeSlider(
                    lowerValue: snapshot.data.priceRange.low,
                    upperValue: snapshot.data.priceRange.high,
                    max: 1000000.0,
                    min: 100000.0,
                    divisions: 19,
                    showValueIndicator: true,
                    valueIndicatorMaxDecimals: 0,
                    onChanged: (double lower, double upper) {
                      filterEditBloc.onPriceRangeChanged.add(Range(low: lower,high: upper));
                    },
                  ),

I can see the thumbs, they are correclty positionned but I cannot move them? The onChanged is never triggered :( Any idea?

Thanks

boeledi commented 6 years ago

Hi Alexandre,

I don't understand since I tried to reproduce the issue but with the following code, it works:

class TestPage extends StatefulWidget {
  @override
  _TestPageState createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  double priceRangeLow = 200000.0;
  double priceRangeHigh = 300000.0;

  @override
  Widget build(BuildContext context) {

    return Container(
      padding: const EdgeInsets.all(15.0),
      child: RangeSlider(
                    lowerValue: priceRangeLow,
                    upperValue: priceRangeHigh,
                    max: 1000000.0,
                    min: 100000.0,
                    divisions: 19,
                    showValueIndicator: true,
                    valueIndicatorMaxDecimals: 0,
                    onChanged: (double lower, double upper) {
print('$lower / $upper');
                    },
                  ),
    );
  }
}

Here is a snapshot: range_slider_github_1

Maybe could provide a bit more of your code, and especially, focusing on the way you are rendering ?

Thanks

boeledi commented 6 years ago

Hi Alexandre,

I have applied to small fix to cover the case where the RangeSlider would be instantiated via ListView.builder()

AlexandreRoba commented 6 years ago

Hi Didier,

Excellent! That solved the issue. It works like a charm. Thanks for this 👍

Alex