Skip to content

[material_ui] Fix floating-point rounding errors for discrete Slider and RangeSlider - #13022

Merged
auto-submit[bot] merged 3 commits into
flutter:mainfrom
hannah-hyj:material-slider-discrete-rounding
Sep 28, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:mainfrom
hannah-hyj:material-slider-discrete-rounding

Conversation

@hannah-hyj

@hannah-hyj hannah-hyj commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Fixes floating-point rounding errors when calculating values for discrete Slider and RangeSlider.

Ports flutter/flutter#187393 to material_ui.
Fixes flutter/flutter#39510

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 25, 2026
@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Sep 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses floating-point rounding errors in the Slider and RangeSlider components by updating the _lerp methods to correctly handle discrete divisions. It also includes a changelog entry and new widget tests to verify the fix. The reviewer recommends adding value.isFinite checks to the _lerp methods to prevent potential UnsupportedError crashes in production when processing non-finite values.

Comment thread packages/material_ui/lib/src/range_slider.dart
Comment thread packages/material_ui/lib/src/slider.dart
@QuncCccccc QuncCccccc changed the title [material_ui] Fix floating-point rounding errors for discrete Slider … [material_ui] Fix floating-point rounding errors for discrete Slider and RangeSlider Sep 28, 2026

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some comments for tests. Thanks!

Comment thread packages/material_ui/test/range_slider_test.dart Outdated
Comment thread packages/material_ui/test/range_slider_test.dart
Comment thread packages/material_ui/test/slider_test.dart
…and RangeSlider

Fixes floating-point rounding errors when calculating values for discrete `Slider` and `RangeSlider`.

Ports flutter/flutter#187393 to `material_ui`.
Fixes flutter/flutter#39510
@hannah-hyj
hannah-hyj force-pushed the material-slider-discrete-rounding branch from b706b60 to bd4dff6 Compare September 28, 2026 21:51
@hannah-hyj

Copy link
Copy Markdown
Member Author

comments resolved

@hannah-hyj hannah-hyj added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 28, 2026
@auto-submit
auto-submit Bot merged commit bcc6dcf into flutter:main Sep 28, 2026
13 checks passed
pull Bot pushed a commit to g-star1024/flutter that referenced this pull request Sep 29, 2026
…er#193507)

flutter/packages@ba0364a...3c6ce59

2026-09-29 [email protected] [cupertino_icons] Migrate to
`cupertino_ui` (flutter/packages#12649)
2026-09-29 [email protected] Manual roll Flutter from
4fcd90b to c5a061b (222 revisions) (flutter/packages#13060)
2026-09-28 [email protected] Enable Built-in Kotlin in all Flutter
Android Plugin Example Apps (flutter/packages#12883)
2026-09-28 [email protected] Enable Built-in Kotlin for
`interactive_media_ads` (flutter/packages#12912)
2026-09-28 [email protected] [google_maps_flutter] Adopt Pigeon's
Kotlin 'suspend' support (flutter/packages#12980)
2026-09-28 [email protected] [material_ui] Fix floating-point
rounding errors for discrete Slider and RangeSlider
(flutter/packages#13022)
2026-09-28 [email protected] [google_sign_in] PR 4/4 Convert
the Pigeon host API from Objective-C to Swift (flutter/packages#12658)
2026-09-28 [email protected]
[google_maps_flutter] Disable flaky web tests blocking latest flutter ->
packages roll (flutter/packages#13047)
2026-09-28 [email protected] [material_ui] Add fontFeatures and
fontVariations to TextTheme.apply() (flutter/packages#12879)
2026-09-28 [email protected]
[in_app_purchase_storekit] Disable flaky tests blocking latest flutter
-> packages roll (flutter/packages#13048)
2026-09-28 [email protected] Sync release-material_ui-1.5.0 to
main (flutter/packages#13051)
2026-09-28 [email protected] Sync release-go_router-18.0.2 to
main (flutter/packages#13050)
2026-09-28 [email protected] [google_fonts] Migrate to material_ui &
cupertino_ui (flutter/packages#13006)
2026-09-28 [email protected] [go_router_builder] Reland material_ui
migration (flutter/packages#12995)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discrete Slider/RangeSlider has interpolation (?) errors

2 participants