Skip to content

Discrete Slider/RangeSlider has interpolation (?) errors #39510

Closed
flutter/packages
#13022

Description

@repentsinner

Steps to Reproduce

  1. Create a discrete Slider/RangeSlider with min:0.0, max:35.0, divisions: 35 (or see main.dart)
  2. Build on Windows & run on a Pixel 2 or build on MacOS and run on an iPhone 7.
  3. Slide any of the thumbs to the 29th position.
  4. Expect the value to be 29.0, but instead receive 29.000000000000004

This also happens with:

max/divisions value
22 14.999999999999998
23 12.999999999999998
25 7.000000000000001, 14.000000000000002
...
35 29.000000000000004
38 21.000000000000004
39 25.000000000000004, 30.999999999999996
...

Current workaround is to insert .roundToDouble() methods in all of the onChange* callbacks to clean up the values before passing them out to the consumer.

Thanks for considering!

Logs

Analyzing flutter_range_slider_test...
No issues found! (ran in 1.2s)
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Microsoft Windows [Version 10.0.18362.327], locale en-US)
    • Flutter version 1.7.8+hotfix.4 at C:\Users\deg\Development\flutter
    • Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0

 
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at C:\Users\deg\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.4)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 37.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[√] VS Code (version 1.37.1)
    • VS Code at C:\Users\deg\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.3.0

[√] Connected device (1 available)
    • Pixel 2 • FA79E1A01225 • android-arm64 • Android 9 (API 28)

• No issues found!

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 30, 2019
  2. HansMuller commented on Aug 30, 2019

    @HansMuller
    Contributor

    CC @clocksmith - maybe we're missing a clamp?

  3. jonans commented on Apr 23, 2020

    @jonans

    Seeing the same problem probably due to floating point error. Any plans on a fix ?

                    Slider.adaptive(value: widget._val,
                              label: widget._val.toString(),
                              onChanged: (x){
                                  widget._val= x; 
                                  setState((){});
                              },
                              min: 0,
                              max: 5,
                              divisions: 5 ~/ 0.2 ,
                     )
    

    slider-rounding-error

  4. self-assigned this
    on Apr 23, 2020
  5. removed their assignment
    on Jun 18, 2020
  6. markusaksli-nc commented on Jul 20, 2020

    @markusaksli-nc
    Contributor

    Reproducible on the latest master 1.21.0-2.0.pre.66.

    flutter doctor -v
    [√] Flutter (Channel master, 1.21.0-2.0.pre.66, on Microsoft Windows [Version 10.0.18362.900], locale et-EE)
       • Flutter version 1.21.0-2.0.pre.66 at C:\Development\flutter_master
       • Framework revision 54c9441723 (2 days ago), 2020-07-17 18:56:12 -0400
       • Engine revision d327828632
       • Dart version 2.9.0 (build 2.9.0-21.0.dev 9dca49e71e)
    
    
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
       • Android SDK at C:\Users\Isa\AppData\Local\Android\sdk
       • Platform android-30, build-tools 30.0.0
       • Java binary at: C:\Users\Isa\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763\jre\bin\java
       • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
       • All Android licenses accepted.
    
    [√] Chrome - develop for the web
       • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    
    [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.6.4)
       • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
       • Visual Studio Community 2019 version 16.6.30309.148
       • Windows 10 SDK version 10.0.18362.0
    
    [√] Android Studio (version 4.0)
       • Android Studio at C:\Users\Isa\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763
       • Flutter plugin version 47.1.2
       • Dart plugin version 193.7361
       • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    
    [√] VS Code (version 1.47.2)
       • VS Code at C:\Users\Isa\AppData\Local\Programs\Microsoft VS Code
       • Flutter extension version 3.12.2
    
    [√] Connected device (5 available)
       • SM G950F (mobile)       • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
       • sdk gphone x86 (mobile) • emulator-5554      • android-x86    • Android 11 (API 30) (emulator)
       • Windows (desktop)       • windows            • windows-x64    • Microsoft Windows [Version 10.0.18362.900]
       • Web Server (web)        • web-server         • web-javascript • Flutter Tools
       • Chrome (web)            • chrome             • web-javascript • Google Chrome 84.0.4147.89
    
    • No issues found!
    
  7. thecalamiity commented on Aug 24, 2020

    @thecalamiity
    Contributor

    You mentioned this issue in your merged PR @guidezpl . Should this be closed?

  8. markusaksli-nc commented on Aug 24, 2020

    @markusaksli-nc
    Contributor

    That PR was just a fix for #60715. This is still reproducible on 1.22.0-2.0.pre.36.

    flutter doctor -v
    [√] Flutter (Channel master, 1.22.0-2.0.pre.36, on Microsoft Windows [Version 10.0.19041.450], locale en-US)
        • Flutter version 1.22.0-2.0.pre.36 at C:\Development\flutter_master
        • Framework revision d30e36ba8c (2 days ago), 2020-08-21 22:36:03 -0400
        • Engine revision d495da20d0
        • Dart version 2.10.0 (build 2.10.0-49.0.dev)
    
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
        • Android SDK at C:\Users\marku\AppData\Local\Android\sdk
        • Platform android-30, build-tools 30.0.1
        • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
        • All Android licenses accepted.
    
    [√] Chrome - develop for the web
        • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    
    [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.6.5)
        • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
        • Visual Studio Community 2019 version 16.6.30320.27
        • Windows 10 SDK version 10.0.18362.0
    
    [√] Android Studio (version 4.0)
        • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763
        • Flutter plugin version 47.1.2
        • Dart plugin version 193.7361
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    
    [√] Connected device (4 available)
        • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
        • Windows (desktop)           • windows       • windows-x64    • Microsoft Windows [Version 10.0.19041.450]
        • Web Server (web)            • web-server    • web-javascript • Flutter Tools
        • Chrome (web)                • chrome        • web-javascript • Google Chrome 84.0.4147.125
    
    • No issues found!
    
  9. danielgomezrico commented on Jul 31, 2021

    @danielgomezrico
    Contributor

    This is still happening on flutter 2.2.0

  10. apoleo88 commented on Nov 18, 2021

    @apoleo88

    It is, also if you use

    min: 40,
    max: 42,
    division: 10,
    

    and you slide to the last value you will get as value 42.00000000000001 that is greater than max and get a bigger Exception:

    'package:flutter/src/material/slider.dart': Failed assertion: line 166 pos 15: 'value >= min && value <= max': is not true.

    And it won't render!

  11. 21 remaining items

  12. removed
    a: text inputEntering text in a text field or keyboard related problems
    on Jul 18, 2023
  13. J3Unknown commented on Nov 1, 2025

    @J3Unknown

    is this issue still exist or has been solved?

  14. self-assigned this
    on Jun 8, 2026
  15. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  16. github-actions commented on Oct 12, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions