Skip to content

feat(slider): add NakedSliderState.visualPercentageOf#79

Merged
leoafarias merged 1 commit into
mainfrom
feat/slider-visual-percentage-of
Jul 21, 2026
Merged

feat(slider): add NakedSliderState.visualPercentageOf#79
leoafarias merged 1 commit into
mainfrom
feat/slider-visual-percentage-of

Conversation

@leoafarias

Copy link
Copy Markdown
Member

What

Adds NakedSliderState.visualPercentageOf(double percentage) — maps a logical fraction (0 = min, 1 = max) to its physical alignment along the track (0 = left/top edge, 1 = right/bottom edge), accounting for orientation, textDirection, and inverted.

visualPercentageAt(int index) now delegates to it. Its behavior is unchanged.

Why

visualPercentageAt is keyed by a thumb index, so a consumer that needs the visual position of a point not tied to a thumb — for example the origin of a single-thumb range fill — has no way to ask for it and must reimplement the RTL/vertical/inverted flip chain itself. This lifts that logic onto the state that already owns orientation/textDirection/inverted, so downstream code can call it instead of duplicating it.

Changes

  • NakedSliderState.visualPercentageOf — new public method
  • visualPercentageAt delegates to it (no behavior change)
  • Unit test covering LTR / RTL / vertical / inverted and the visualPercentageAt delegation invariant

Verification

  • dart format clean, dart analyze clean
  • All slider tests pass (test/src/naked_slider_test.dart)

Purely additive and backward compatible.

Map an arbitrary logical fraction (0 = min, 1 = max) to its physical
alignment along the track (0 = left/top, 1 = right/bottom), accounting
for orientation, text direction, and inversion.

visualPercentageAt is keyed by thumb index, so consumers needing the
visual position of a non-thumb point (e.g. the origin of a range fill)
had to reimplement the flip chain. visualPercentageAt now delegates to
the new method and its behavior is unchanged.
@github-actions

Copy link
Copy Markdown
Contributor

LCOV of commit f65aa98 during Flutter CI #265

	(use "lcov --ignore-errors deprecated,deprecated ..." to suppress this warning)
Reading tracefile /tmp/__zgosalvez_github-actions-report-lcov/lcov.info.
Summary coverage rate:
  source files: 22
  lines.......: 89.6% (2945 of 3287 lines)
  functions...: no data found
  branches....: no data found
Message summary:
  1 warning message:
    deprecated: 1

Files changed coverage rate:
  	(use "lcov --ignore-errors deprecated,deprecated ..." to suppress this warning)
                                                                   |Lines       |Functions  |Branches    
  Filename                                                         |Rate     Num|Rate    Num|Rate     Num
  packages/naked_ui/lib/src/naked_slider.dart                      |89.0%    373|    -     0|    -      0

@leoafarias
leoafarias merged commit 3ec12f0 into main Jul 21, 2026
7 checks passed
@leoafarias
leoafarias deleted the feat/slider-visual-percentage-of branch July 21, 2026 01:37
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

Successfully merging this pull request may close these issues.

1 participant