-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Added onChangeStart and onChangeEnd to CupertinoSlider #17535
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
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
|
I signed it! |
|
CLAs look good, thanks! |
… and onChangeEnd documentation
|
Thanks @dcaraujo0872! This looks great, but could we bother you to add a test for it too? |
|
Sure thing @gspencergoog, on it. :) |
| widget.onChangeEnd(_lerp(value)); | ||
| } | ||
|
|
||
| // Returns a number between min and max, proportional to value, which must |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is off here.
| /// | ||
| /// ```dart | ||
| /// new CupertinoSlider( | ||
| /// value: _duelCommandment.toDouble(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to add the magic comment incantation:
// Examples can assume:
// int _duelCommandment = 1;at the top of the file, just below the imports (see the top of material/slider.dart for an example) to prevent the dartdoc syntax checker from failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I gave you only partially correct advice: you need that incantation, but you'll have to change the name of the variable, since that name is already used in the material slider.
Maybe something like _cupertinoSliderValue. More boring, but has the advantage of being unique. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! Well my own fault as well because I didn't check other source files. I saw the CI logs a few minutes ago and was wondering why it was failing. Thanks @gspencergoog :)
| double _lerp(double value) { | ||
| assert(value >= 0.0); | ||
| assert(value <= 1.0); | ||
| return value * (widget.max - widget.min) + widget.min; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just replace calls to _lerp with this (and eliminate _lerp):
lerpDouble(widget.min, widget.max, value);The 0-1 enforcement is already being done in the render object.
…no-slider-onchangestart

This is a follow up on issue #17169 and the pull request #17298
This pull request adds the onChangeStart and onChangeEnd callbacks for CupertinoSlider. These are called when a user starts and ends a change respectively.