Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it a way to have values from min up to max-to-infinite #34

Open
chamartt opened this issue Nov 23, 2020 · 1 comment
Open

Is it a way to have values from min up to max-to-infinite #34

chamartt opened this issue Nov 23, 2020 · 1 comment

Comments

@chamartt
Copy link

Hi,

I need to range my sider from min to max values.
If the max cursor is moved at the end of the track, the upperValue must be infinite.

Is it a simple way to do this and display to the user on the live value indicator that he's selecting max and upper values?
I can't setState on onChanged method for performance needs.

In perfect world, I would live have 1 to 5, and if the user move the cursor after 5, the upperValue should be inifinite and it should be writted on the value indicator.

Thank you for your help !

@chamartt
Copy link
Author

chamartt commented Nov 23, 2020

This is my code currently, but it does support live displaying of "5+" on the value indicator:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lalgodepaulo/tools/pauloColors.dart';
import 'package:flutter_range_slider/flutter_range_slider.dart' as frs;

class MyPage extends StatefulWidget {
const MyPage();

@OverRide
_MyPage createState() => _MyPage();
}

class _MyPage extends State {
double _lowerValue;
double _upperValue;
double _upperValueForFilter;
String _upperValueDisplayed;

@OverRide
void initState() {
super.initState();

_lowerValue = 1.0;
_upperValue = 5.0;
_upperValueDisplayed = '5+';
_upperValueForFilter = double.maxFinite;

}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Column(children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
_lowerValue.toStringAsFixed(2),
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Colors.black45,
),
),
Text(
_upperValueDisplayed,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Colors.black45,
),
)
])),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: SliderTheme(
data: SliderTheme.of(context).copyWith(
activeTickMarkColor: PauloColors.purple,
activeTrackColor: PauloColors.purple,
inactiveTrackColor: PauloColors.purple.withOpacity(0.2),
trackHeight: 5.0,
thumbColor: PauloColors.purple,
valueIndicatorColor: PauloColors.purple,
showValueIndicator: ShowValueIndicator.always),
child: frs.RangeSlider(
allowThumbOverlap: true,
min: 1,
max: 5,
lowerValue: _lowerValue,
upperValue: _upperValue,
valueIndicatorMaxDecimals: 2,
showValueIndicator: true,
onChanged: (double newLowerValue, double newUpperValue) {},
onChangeEnd: (double newLowerValue, double newUpperValue) {
setState(() {
_lowerValue = newLowerValue;
_upperValue = newUpperValue;
_upperValueDisplayed = newUpperValue < 5 ? newUpperValue.toStringAsFixed(2) : '5+';

              /* FILTER MY DISPLAY RESULTS WITH NEW RANGE VALUES */
              //_upperValueForFilter = newUpperValue < 5 ? newUpperValue : double.maxFinite;
              //...
            });
          },
        )),
  ),
]));

}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant