3.1.0 Lifecycle, accessibility and spinner fixes #
Bug fixes
- Fixes a caller-owned
LoadSwitchController being left loading forever when a
LoadSwitch.controlled was disposed, changed mode, or had its controller
swapped while an async toggle was still in flight. The widget now tracks the
controller whose loading state it switched on and always hands it back
- Fixes a managed switch staying loading forever after being rebuilt from
isLoading: true back to the default. An omitted isLoading now means "not
loading" instead of "do not synchronize"; loading driven by the widget's own
toggle is tracked separately and is unaffected
SpinStyle.cupertino now honors spinColor instead of ignoring it
SpinStyle.waveSpinner now renders SpinKitWaveSpinner instead of
duplicating SpinStyle.waveStart
UI and accessibility
- The thumb now uses directional alignment, so the switch lays out correctly in
right-to-left locales
- Inactive switches are reachable by keyboard, so keyboard users get the same
onTap feedback pointer users already had
- Adds a keyboard focus indicator, plus
focusNode, autofocus and
focusColor
- Adds
semanticLabel, loadingSemanticHint and disabledSemanticHint for
configurable screen reader announcements
Quality
- Constructors now reject non-positive or non-finite
width, height and
spinStrokeWidth, and negative animation durations
- Documents that
spinnerAnimationDuration does not affect the native Material
and Cupertino indicators, which animate at a fixed rate
- Adds
LoadSwitchController.clearLoadingAfterFrame(), used by the widget to
release loading during teardown without notifying listeners while the widget
tree is locked
- Test suite grown from 23 to 47 tests; core library is now at 100% line
coverage
Breaking API changes
- Replaces the overloaded
LoadSwitch constructor with explicit
LoadSwitch.managed and LoadSwitch.controlled modes
- Renames
future to onToggle and onChange to onChanged
- Splits
animationDuration into switchAnimationDuration and
spinnerAnimationDuration
- Changes
onError to include both Object and StackTrace
- Aligns
LoadSwitchController.executeWithLoading() naming with the widget API
Bug fixes
- Fixes controller ownership bugs when swapping between managed and controlled
modes
- Hardens async updates against dispose and stale controller writes
- Prevents managed switches from becoming tappable again after a parent rebuild
while an async toggle is still in flight
- Fixes spinner sizing, including the Cupertino spinner radius
UI and accessibility
- Adds keyboard activation support
- Uses proper switch-style
toggled semantics instead of checkbox-style
semantics
- Expands tests to cover controller behavior, lifecycle, async regressions,
semantics, and all spinner styles
- Raises the minimum supported SDKs to Dart 3.6 and Flutter 3.27
Docs and examples
- Updates the README and examples for the new API
- Migration guide for the breaking changes is available in the README
- Removes redundant
AnimationControllers from toggle styles
- Internal code cleanup and optimizations
- Improves examples
- Adds
LoadSwitchController for programmatic control of the switch
- Switch now supports both controlled and uncontrolled modes
- Controller features:
- Programmatic value toggling via
toggle() method
- Loading state management via
executeWithLoading()
- External observation of state changes via
addListener()
- Programmatic control of active state
- Example usage with controller pattern included
- Replace
withOpacity with withValues
- New parameter
style. The library extends flutter_spinkit internally adding some fancy spin animations. Keep in mind you can also edit the thumbDecoration & switchDecoration for different color & shapes. The examples have the default circular thumb with white color. The default style is SpinStyle.material.
| material |
cupertino |
chasingDots |
 |
 |
 |
| circle |
cubeGrid |
dancingSquare |
 |
 |
 |
| doubleBounce |
dualRing |
fadingCircle |
 |
 |
 |
| fadingCube |
fadingFour |
fadingGrid |
 |
 |
 |
| foldingCube |
hourGlass |
pianoWave |
 |
 |
 |
| pouringHourGlass |
pulse |
pulsingGrid |
 |
 |
 |
| rotatingCircle |
rotatingPlain |
spinningCircle |
 |
 |
 |
| spinningLines |
squareCircle |
threeBounce |
 |
 |
 |
| threeInOut |
wanderingCubes |
waveStart |
 |
 |
 |
| waveCenter |
waveEnd |
waveSpinner |
 |
 |
 |
onError(error) : Callback when the Future throws an error
- Internal code optimization and clean up
onTap(bool) : Will always trigger even if the toggle is not active
onTap(bool) will trigger before the future, the bool is the value of the switch when tapped
onChange(bool) will trigger after the future, the bool is the response of the future
- Adds new parameter
isActive to choose whether the toggle is active and can be interacted
- Tweaks
switchDecoration & thumbDecoration to also expose the activity status
- Adds
thumbSizeRatio (0 - 1) to control the size of the thumb
Default:

thumbSizeRation = 0.8

- Adds
isLoading flag to manually change the loading state when needed
- Fixes switch not updating when
value was changed
- Simplifies API by removing redundant parameters.
- Fixes dimension issues when specifying height and width to the switch.
- Removes tests for now
Check the README for the examples.
- Updates flutter_lints dependency
- Removes unnecessary parent widgets (
Scaffold & Center).
- Removes forgotten print outputs.