material-components / material-components/material-components-android

[Slider] java.lang.IllegalStateException: valueFrom(2.0) must be smaller than valueTo(2.0)

Open
#2,787 9 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Widget: Slider
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:**
When i set value to slider having same valueTo and ValueFrom it crash

Crash Logs:
java.lang.IllegalStateException: valueFrom(2.0) must be smaller than valueTo(2.0)
at com.google.android.material.slider.BaseSlider.validateValueFrom(BaseSlider.java:520)
at com.google.android.material.slider.BaseSlider.validateConfigurationIfDirty(BaseSlider.java:608)
at com.google.android.material.slider.BaseSlider.onDraw(BaseSlider.java:1662)
at android.view.View.draw(View.java:22644)
at android.view.View.updateDisplayListIfDirty(View.java:21519)

Suggestion:
We should not throw exception instead we should accept the same value

private void validateValueFrom() {
if (valueFrom >**=** valueTo) {
throw new IllegalStateException(
String.format(EXCEPTION_ILLEGAL_VALUE_FROM, valueFrom, valueTo));
}
}

private void validateValueTo() {
if (valueTo <**=** valueFrom) {
throw new IllegalStateException(
String.format(EXCEPTION_ILLEGAL_VALUE_TO, valueTo, valueFrom));
}
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in BaseSlider.java at validateValueFrom(), validateValueTo(), and validateConfigurationIfDirty(), using the reported stack trace to follow when validation runs. Check the surrounding slider configuration behavior before changing the equal-bound handling; done means sliders with valueFrom and valueTo both set to 2.0 no longer throw while existing invalid configurations remain handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.