smooth_ios_style_toggle 0.2.0
smooth_ios_style_toggle: ^0.2.0 copied to clipboard
A smooth, fully customizable iOS-style toggle with a pill thumb (~1.7× height), adaptive labels beside or inside the thumb, drag gestures, validated sizing, and built-in Flutter state management (Valu [...]
0.2.0 #
Added #
- Optional
thumbWidthonSmoothToggleStyle(validated betweentrackWidth / 4andtrackWidth / 2). - Validated dimensions (debug asserts):
trackHeight25–70,trackPaddingmust leave ≥ 8 px for the thumb,thumbWidthbounds when set. - Adaptive label sizing: font sizes scale with track/thumb size; labels use
FittedBoxso long text (e.g.Online/Offline) fits beside or inside the thumb. - Style helpers:
fontSizeForThumbText(),fontSizeForTrackLabel(),maxTrackLabelWidth(),resolveActiveTextStyle(),resolveInactiveTextStyle(), and related layout helpers. semanticLabelonSmoothToggleStylefor screen-reader names (wired toSemantics.label).- Expanded widget & unit tests (21 tests): drag, keyboard, disabled state, theme, thumb clamping, and style validation.
Changed #
- Default
trackHeightis 30 (was 31). - Default thumb width is ~1.7× thumb height, clamped so it never exceeds half of
trackWidth. - Default animation: 200 ms with
Curves.easeInOut(was 220 ms /easeInOutCubic). - Parent-owned state (
value+onChanged/setState/ GetX): animation syncs after rebuild instead of racing ahead of the parent. - Drag end no longer fires a duplicate tap; drag cancel snaps the thumb back to the current value.
Fixed #
- Toggle could double-flip when releasing after a drag (tap fired after drag end).
- Animation / value desync when the parent updated state asynchronously.
- Oversized default thumb on narrow
trackWidthvalues (thumb now clamped to fit the track).
0.1.1 #
- Default
trackWidthis 110 (was 74 in early drafts).
0.1.0 #
- Initial release of
SmoothIOSTogglewith pill thumb, inline labels,SmoothToggleController, andSmoothToggleTheme. - Tap, drag, keyboard, semantics, and haptic feedback support.
- Works on Android, iOS, Web, Windows, macOS, and Linux.