how save range slider values in flutter

Viewed 484

As You can see I use provider for passing my data and in here I want save rangeslider values with a function and when I use start and end values of rangeslider it doesnt work any more I need more information to how this is happining but when I use that my rangeslider after changing back to first position here is my code

final range =
    ModalRoute.of(context).settings.arguments as Map<String, dynamic>;
final atta = Provider.of<AttProvider>(context);
RangeValues values = RangeValues(
  range['min'].toDouble(),
  range['max'].toDouble(),
);
var start = range['min'];
var end = range['max'];
return Scaffold(
  appBar: AppBar(
    centerTitle: true,
    title: Text(range['title']),
  ),
  body: StatefulBuilder(
    builder: (context, setState) => Column(children: [
      Padding(
        padding: const EdgeInsets.all(8.0),
        child: Row(
          children: [
            Text('Start in'),
            Text(
              ' $start',
              style: TextStyle(color: Colors.black),
            ),
            Spacer(),
            Text('End in '),
            Text(
              '$end',
              style: TextStyle(color: Colors.black),
            ),
          ],
        ),
      ),
       RangeSlider(
        onChangeEnd: (vala) {
          atta.addItem(
              range['id'], 0, vala.start.toInt(), vala.end.toInt(), true);
        },
        values: values,
        min: range['min'].toDouble(),
        max: range['max'].toDouble(),
        onChanged: (val) {
          setState(() {
            values = val;
            start = val.start.toInt();
            end = val.end.toInt();
          });
        },
      ),
    ]),
  ),
);
0 Answers
Related